Skip to content

Instantly share code, notes, and snippets.

@d1mach
Created April 4, 2016 10:39
Show Gist options
  • Save d1mach/5d315a06c6403c94d64131191161c2e4 to your computer and use it in GitHub Desktop.
Save d1mach/5d315a06c6403c94d64131191161c2e4 to your computer and use it in GitHub Desktop.
UserDir functionality with PHP support for NGINX
# userdir.conf
server {
listen 80;
server_name localhost;
client_max_body_size 20M;
# Declare index files in advance to use .php extension as a selector
# to choose the correct location clause
index index.php index.html index.htm;
# For .php files pass the scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ ^/~(.+?)(/.+\.php)$ {
alias /home/$1/public_html$2;
autoindex on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
# For serving static files and autogenerated directory indices
# turn autoindex on
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
autoindex on;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment