Nginx Configuration
SiteX CMS works best with Nginx. Below is the recommended server block configuration.
Basic Server Block
server {
listen 80;
listen [::]:80;
server_name yoursite.com www.yoursite.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yoursite.com www.yoursite.com;
root /var/www/yoursite.com/public;
index index.php;
# SSL (managed by CloudPanel / Let's Encrypt)
ssl_certificate /etc/letsencrypt/live/yoursite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yoursite.com/privkey.pem;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript
text/xml application/xml text/javascript image/svg+xml;
gzip_min_length 1000;
# Static assets with long cache
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Block access to sensitive files
location ~ /\.(env|git|htaccess) {
deny all;
return 404;
}
location ~ ^/(config|core|controller|data|logs)/ {
deny all;
return 404;
}
# Main routing - send all requests to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP processing
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
# Block PHP execution in upload directories
location ~* /uploads/.*\.php$ {
deny all;
return 404;
}
# Logging
access_log /var/log/nginx/yoursite.com.access.log;
error_log /var/log/nginx/yoursite.com.error.log;
}
CloudPanel Configuration
If you're using CloudPanel:
- Create a new PHP site in CloudPanel
- Set the Document Root to the SiteX installation directory
- Go to Vhost tab and replace the default config with the server block above
- Adjust the
fastcgi_passpath to match your PHP version - Enable SSL via CloudPanel's Let's Encrypt integration
Key Points
- Document root - Point to the SiteX root directory (where
index.phplives) - URL rewriting - The
try_filesdirective routes all requests throughindex.php - Security - The config blocks access to
config/,core/,controller/,data/, andlogs/ - PHP version - Update the
fastcgi_passsocket path to match your installed PHP version
Testing
After configuring Nginx, test and reload:
sudo nginx -t
sudo systemctl reload nginx