Nginx rewrite rules for concrete5 cms

 

 

I am often asked about proper rewrite rules for concrete 5 when using nginx web server. I have found the rules below to be equivalent with the default apache2 rewrite rules:

Inside an nginx site config file:

server {
listen 80;
server_name yoursitename.com
root /path/to/your/web/folder;
index index.php;
error_log /path/to/your/error.log;
location /{
try_files $uri $uri/ /index.php$request_uri;
}
location ~ .php($|/) {
set $script $uri;
if ($uri ~ “^(.+.php)(/.+)”) {
set $script $1;
}
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_intercept_errors on;
fastcgi_next_upstream error invalid_header timeout http_500;
fastcgi_pass 127.0.0.1:port or your fastcgi socket file
}
}

Please note that this is not meant to be a copy paste solution, neither a perfect one. You should inspect and adjust the parameters above to your paths and desired values. The above can be used both for fastcgi and FPM.
I suggest that you create a seperate fpm pool for each website as its more secure and less troublesome than running all your virtual hosts as the same php user. Perhaps one day i will publish a step by step guide to setup an nginx+php5-fpm multiuser + mysql webserver. Let me know if you are interested.
Print Friendly

You may also like...