Skip to content

Instantly share code, notes, and snippets.

@ayonliu
Last active November 27, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayonliu/786da81994a386436b82 to your computer and use it in GitHub Desktop.
Save ayonliu/786da81994a386436b82 to your computer and use it in GitHub Desktop.
nginx configure for mydomain.com, include by nginx.conf
# Upstream to abstract backend connection(s) for php
upstream php {
# server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
## Your website name goes here.
server_name mydomain.com www.mydomain.com ;
## Your only path reference.
root /app/site/mydomain.com/web;
access_log /var/log/nginx/mydomain.com.access.log william;
error_log /app/site/mydomain.com/logs/http_error.log error;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /directory/ {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /directory/index.php?$args;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~* \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#include fastcgi.conf;
#fastcgi_intercept_errors on;
fastcgi_pass php;
include /etc/nginx/fastcgi.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 36000;
log_not_found off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment