Skip to content

Instantly share code, notes, and snippets.

@pgodel
Created July 17, 2011 16:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgodel/1087742 to your computer and use it in GitHub Desktop.
Save pgodel/1087742 to your computer and use it in GitHub Desktop.
nginx php config sample
server {
set $website_host "mywonderfulwebsite.org";
set $website_root "/var/www/mywonderfulwebsite/web";
set $default_controller "index.php";
set $symfony_root "/var/www/mywonderfulwebsite/lib/vendor/symfony";
listen 80;
server_name $website_host;
# Gzip
gzip on;
gzip_min_length 1000;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.";
access_log /var/log/nginx/$website_host.access.log;
root $website_root;
index $default_controller;
charset utf-8;
location /sf {
# path to folder where all symfony assets are located
alias $symfony_root/data/web/sf;
expires max;
}
location / {
# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
expires max;
break;
}
if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
rewrite ^(.*) /$default_controller$1 last;
}
}
location ~ "^(.+\.php)($|/)" {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)($|/)") {
set $script $1;
}
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $website_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment