Nginx
Recommended Nginx configuration.
Below is a working Nginx configuration example. Adjust paths and PHP-FPM socket to your environment.
Server block #
server {
listen 80;
server_name velvetcms.com www.velvetcms.com;
root /var/www/velvetcms/public;
index index.php;
access_log /var/log/nginx/velvetcms.access.log;
error_log /var/log/nginx/velvetcms.error.log warn;
client_max_body_size 20m;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
# Deny access to sensitive files
location ~ \.(?:ht|git|env) {
deny all;
}
# Static asset caching
location ~* \.(?:css|js|jpg|jpeg|png|gif|ico|svg|webp|woff|woff2|ttf|otf)$ {
try_files $uri /index.php?$query_string;
expires 12h;
access_log off;
}
}
PHP-FPM socket #
Adjust fastcgi_pass to match your PHP-FPM configuration:
| Distribution | Socket path |
|---|---|
| Fedora/RHEL | /run/php-fpm/www.sock |
| Ubuntu/Debian | /run/php/php8.4-fpm.sock |
| Arch | /run/php-fpm/php-fpm.sock |