Skip to content

Instantly share code, notes, and snippets.

@laozhu
Created October 8, 2012 03:31
Show Gist options
  • Save laozhu/3850586 to your computer and use it in GitHub Desktop.
Save laozhu/3850586 to your computer and use it in GitHub Desktop.
nginx conf file
server {
listen 80;
server_name www.laozhu.me laozhu.me;
client_max_body_size 512M;
if ($http_host !~ 'www.laozhu.me') {
rewrite ^/(.*)$ http://www.laozhu.me/$1 permanent;
}
location / {
root /home/laozhu/www/laozhu.me;
index index.php index.html;
try_files $uri $uri/ /index.php;
}
location ~* ^\.(jpg|jpeg|gif|png)$ {
root /home/laozhu/www/laozhu.me;
access_log off;
log_not_found off;
expires max;
}
location ~* ^/(favicon\.ico|crossdomain\.xml|robots\.txt)$ {
root /home/laozhu/www/laozhu.me;
access_log off;
log_not_found off;
expires max;
}
location ~* ^\.(css|js)$ {
root /home/laozhu/www/laozhu.me;
access_log off;
expires 30d;
}
location ~* ^/sitemap\.xml$ {
root /home/laozhu/www/laozhu.me;
access_log off;
expires 1d;
}
location ~* /\. {
root /home/laozhu/www/laozhu.me;
access_log off;
log_not_found off;
deny all;
}
location ~* \.php$ {
root /home/laozhu/www/laozhu.me;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
include /etc/nginx/fastcgi.conf;
}
access_log /home/laozhu/log/nginx/access_log main;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment