Created
March 23, 2012 05:56
-
-
Save cantremember/2167455 to your computer and use it in GitHub Desktop.
nginx vhost example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
include extra/proxy.conf; | |
include mime.types; | |
listen 80; | |
server_name blog.DOMAIN.NAME; | |
access_log logs/LOGFILE-access.log; | |
###error_log logs/LOGFILE-error.log debug; | |
error_log logs/LOGFILE-error.log; | |
# Settings | General | WordPress address (URL) | |
location /WP-CONTEXT { | |
# physical location on server | |
root /PATH/TO/WP-DIR; | |
index index.php index.html index.htm; | |
# remove virtual path, make it root-relative | |
rewrite ^/WP-CONTEXT(.*)$ $1; | |
# this serves static files that exist without running other rewrite tests | |
if (-f $request_filename) { | |
expires 30d; | |
break; | |
} | |
# addresses '/wp-admin/' and similar vein | |
if (-f $request_filename/index.php) { | |
# produces '...//index.php', acceptable loss | |
rewrite ^(.+)$ /WP-CONTEXT$1/index.php last; | |
} | |
# this sends all non-existing file or directory requests to index.php | |
if (!-e $request_filename) { | |
rewrite ^(.+)$ /WP-CONTEXT/index.php?q=$1 last; | |
} | |
} | |
location ~ \.php$ { | |
# remove virtual path, make it root-relative | |
rewrite ^/WP-CONTEXT(.*)$ $1; | |
fastcgi_pass fastcgi_cluster; | |
fastcgi_index index.php; | |
# physical location on server | |
fastcgi_param SCRIPT_FILENAME /PATH/TO/WP-DIR$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
# Settings | General | Blog address (URL) | |
location / { | |
# WordPress handles this perfectly as-is | |
fastcgi_pass fastcgi_cluster; | |
# physical location on server | |
fastcgi_param SCRIPT_FILENAME /PATH/TO/WP-DIR/index.php; | |
include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment