Nginx Rewrite Rule for FuelCMS

I just  clean up one of the my VPS  yesterday without backup my Nginx conf file and this has causing me wasted almost half of the day re-configure the server, just to document this in case any fuelcms user need this.

I setup ubuntu natty on amazon aws , this latest version of ubuntu server included PHP5-FPM , with some help on the Nginx installation page , I have installed both PHP5-FPM and Nginx 1.0.4  with simple command – apt-get install.

So once the Nginx server is up and running , adding this sites file in /etc/nginx/site-available/domain.com.

*replace domain.com with your own domain
*replace home_path with your web server path

server {
listen 80;
server_name www.domain.com;
rewrite ^/(.*) http://domain.com/$1 permanent;
}
server {
listen 80;
server_name domain.com;
access_log /home_path/log/access.log;
error_log /home_path/log/error.log;

location / {

root /home_path/public/;
index index.php index.html;

if ($request_filename !~ (js|css|images|img|robots\.txt|index\.php.*) ) {
rewrite ^/(.*)$ /index.php/$1 last;
}

if (!-f $request_filename) {
rewrite ^/(.*)(fuel/modules/.*) /$2 last;
rewrite ^/(.*)(/assets/.*) /$2 last;
}

location ^~ /fuel/crons {
deny all;
}

 

location ^~ /fuel/data_backup {
deny all;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ /index.php/
{
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home_path/public$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}

most of the user stop at this point after added this site conf file and find out that their Fuelcms is still not working properly, you need to add another config file increase the buffer which I blogged before .

For Nginx 1.04 , you can just create a buffer.conf in /etc/nginx/conf.d/ with this 2 line, restart Nginx and your Fuelcms should be running well now.

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

You may also like...