вторник, 22 июня 2010 г.

Symphony CMS + nginx config

My primitive nginx site configuration for symphony-cms  (nginx + php-fpm):

server{
 listen 80;
 server_name mydomain.com www.mydomain.com;
 access_log /var/log/nginx/mydomain.access.log;
 #access_log off;
 error_log  /var/log/nginx/mydomain.error.log;
 client_max_body_size 50m;

 root /var/www/mydomain/docs;
  
 location / {
 index index.php index.html;
 
 if (-f $request_filename){
   access_log off;  
   expires   30d;
   break;
 }
 
### BACKEND
 if ($request_filename ~ /symphony/) {
         rewrite ^/symphony/?$ /index.php?mode=administration&$query_string last;
            rewrite ^/symphony(/(.*/?))?$ /index.php?symphony-page=$1&mode=administration&$query_string last;
        }
        
 ##IMAGE RULES
 rewrite ^/image/(.+\.(jpg|gif|jpeg|png|bmp|JPG|GIF|JPEG|PNG|BMP))$ /extensions/jit_image_manipulation/lib/image.php?param=$1 last;

 ### CHECK FOR TRAILING SLASH - Will ignore files
    if (!-f $request_filename) {
          rewrite ^/(.*[^/]+)$ /$1/ permanent;
     }

     ### MAIN REWRITE - This will ignore directories
 if (!-d $request_filename) {
          rewrite ^/(.*)$ /index.php?symphony-page=$1 last;
          
     }

}

# error_page  404              /index.php;
 
 ## Images and static content is treated different
    location ~* ^.+.(xml)$ {
      access_log        off;
      expires           30d;      
    }


## Parse all .php file in the /var/www directory
    location ~ .php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass   backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        
        include fastcgi_params;
        fastcgi_param  QUERY_STRING     $query_string;
        fastcgi_param  REQUEST_METHOD   $request_method;
        fastcgi_param  CONTENT_TYPE     $content_type;
        fastcgi_param  CONTENT_LENGTH   $content_length;
        fastcgi_param DOCUMENT_URI      $document_uri;
        fastcgi_param DOCUMENT_ROOT     $document_root;
        fastcgi_intercept_errors        on;
        fastcgi_ignore_client_abort     off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }

## Disable viewing .htaccess & .htpassword
    location ~ /\.ht {
        deny  all;
    }
}
upstream backend {
        server 127.0.0.1:9000;
}