Nginx

From Alessandro's Wiki
Revision as of 12:22, 1 October 2012 by Xunil (talk | contribs) (Created page with " == Configuration == *; server { listen 80; server_name thedomain.com; access_log logs/access.log; error_log logs/error.log; root /home/swin/oaih/dev/public; i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Configuration

  • server {
listen 80;
server_name thedomain.com;
access_log  logs/access.log;
error_log     logs/error.log;
root /home/swin/oaih/dev/public;
index index.php index.html index.htm; 

FastCGI

location ~ .php$ {
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include /etc/nginx/fastcgi_params;
}
location ~ .php($|/) {
 set $script $uri;
 set $path_info "";
 if ($uri ~ "^(.+.php)(/.+)") {
   set $script $1;
   set $path_info $2;
 }
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php; 
 fastcgi_param SCRIPT_FILENAME $document_root$script;
 fastcgi_param SCRIPT_NAME $script;
 fastcgi_param PATH_INFO $path_info;
}

Rewrite rules

  • rewriting every non existent file to index.php
location / {
  if (!-e $request_filename) {
    rewrite ^/(.*)$ /index.php/$1 last;
  }
}