Last Updated: February 25, 2016
·
876
· jaymabazza

Silverstripe - Nginx Configuration

You might stumble on a problem running silverstripe on nginx. this configuration might help.

server {
        listen 80;

        root /var/www/something
        index index.php;

        server_name www.something.com

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        try_files $uri /sapphire/main.php?url=$uri&$args;

        location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
            expires max;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        location = /robots.txt  { access_log off; log_not_found off; }
        location = /favicon.ico { access_log off; log_not_found off; }

        location ~ /\.          { access_log off; log_not_found off; deny all; }

        location ~ ".+\.php($|/.*)" {
            fastcgi_index index.php;
            fastcgi_pass unix:/tmp/php5-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/?.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }

}