Nginx Configuration
Total CMS ships with .htaccess files for Apache. If you are running Nginx, you will need to add equivalent configuration to your Nginx server block. Nginx does not read .htaccess files.
How Total CMS Routing Works
Section titled “How Total CMS Routing Works”Total CMS uses two layers of URL rewriting:
- Root rewrite — All requests to the
tcms/directory are routed into thepublic/subdirectory - Front controller — Any request that does not match a real file or directory inside
public/is handled byindex.php - Data protection — The
tcms-data/directory must be blocked from direct access
Standalone Installation
Section titled “Standalone Installation”If Total CMS is installed at the document root (or you can set the Nginx root to the public/ directory directly):
server { listen 80; server_name example.com; root /var/www/totalcms/public; index index.php;
# Block direct access to tcms-data location ~* /tcms-data/ { deny all; return 403; }
# Front controller location / { try_files $uri $uri/ /index.php?$query_string; }
# PHP-FPM location ~ \.php$ { fastcgi_pass unix:/var/run/php/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
# Deny access to dotfiles (.htaccess, .env, etc.) location ~ /\. { deny all; }}Subdirectory Installation (Stacks)
Section titled “Subdirectory Installation (Stacks)”When Total CMS is installed inside a subdirectory such as /rw_common/plugins/stacks/tcms/, the configuration needs to account for the path prefix:
# Block direct access to tcms-datalocation ~* /tcms-data/ { deny all; return 403;}
# Route requests into the public/ subdirectory and use front controllerlocation /rw_common/plugins/stacks/tcms/ { try_files $uri $uri/ /rw_common/plugins/stacks/tcms/public/$uri /rw_common/plugins/stacks/tcms/public/index.php?$query_string;}
# PHP-FPM for Total CMSlocation ~ /rw_common/plugins/stacks/tcms/.*\.php$ { fastcgi_pass unix:/var/run/php/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}Adjust the path to match your actual installation directory.
PHP-FPM Socket
Section titled “PHP-FPM Socket”The fastcgi_pass directive must point to your PHP-FPM socket or TCP address. Common values:
| Distribution | Socket Path |
|---|---|
| Ubuntu/Debian | unix:/var/run/php/php8.2-fpm.sock |
| CentOS/RHEL | unix:/var/run/php-fpm/www.sock |
| macOS (Homebrew) | unix:/opt/homebrew/var/run/php-fpm.sock |
| TCP (any) | 127.0.0.1:9000 |
Check your PHP-FPM pool configuration (www.conf) for the exact listen value.
Session Configuration
Section titled “Session Configuration”On Apache, Total CMS can set session lifetime via .htaccess. On Nginx, configure this in your PHP-FPM pool (www.conf) or php.ini instead:
; Set session timeout to 24 hours (matches Total CMS default)php_admin_value[session.gc_maxlifetime] = 86400Verifying Your Configuration
Section titled “Verifying Your Configuration”After updating your Nginx configuration:
- Test the configuration:
nginx -t - Reload Nginx:
systemctl reload nginx - Navigate to your Total CMS admin URL (e.g.,
example.com/tcms/admin) - If you see a 404, double-check the
try_filesdirective and ensure it falls back toindex.php - If you see a 502, verify your PHP-FPM socket path is correct and that PHP-FPM is running