Skip to content

Instantly share code, notes, and snippets.

@reqshark
Created May 3, 2012 02:22
Show Gist options
  • Save reqshark/2582593 to your computer and use it in GitHub Desktop.
Save reqshark/2582593 to your computer and use it in GitHub Desktop.
php site nginx
server
{
listen 80;
server_name whatever.com www.whatever.com;
access_log /srv/www/whatever.com/logs/access.log;
root /srv/www/whatever.com/public_html;
index index.html index.htm index.php index.cgi;
error_page 400 406 407 409 410 411 412 413 414 415 416 417 418 422 423 424 425 426 444 449 450 490 /error/400.html;
error_page 401 /error/401.html;
error_page 402 /error/402.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 408 /error/408.html;
error_page 500 506 507 509 510 /error/500.html;
error_page 501 /error/501.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_page 504 /error/504.html;
error_page 505 /error/505.html;
location = /error/403.html
{
allow all;
}
location ~ \.php$
{
try_files $uri $uri/ @rewrites;
include /etc/nginx/php.conf;
}
location @rewrites {
# Can put some of your own rewrite rules in here
# for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last;
# If nothing matches we'll just send it to /index.php
}
##perl
#location ~ \.pl$
#{
# fastcgi_pass unix:/var/run/fcgiwrap.socket ;
# include /etc/nginx/fastcgi_params;
#}
}
server
{
listen 443;
server_name whatever.com www.whatever.com;
access_log /srv/www/whatever.com/logs/access.log;
root /srv/www/whatever.com/public_html;
index index.html index.htm index.php index.cgi;
ssl on;
ssl_certificate /etc/ssl/certs/server.crt;
ssl_certificate_key /etc/ssl/private/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ~ \.php$
{
try_files $uri $uri/ @rewrites;
include /etc/nginx/php.conf;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment