Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
Last active November 30, 2017 17:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brahimmachkouri/8195978 to your computer and use it in GitHub Desktop.
Save brahimmachkouri/8195978 to your computer and use it in GitHub Desktop.
nginx userdir + php-fpm
server {
listen 80;
server_name localhost;
# ... other default site stuff, document root, etc. ...
location ~ ^/~(?<userdir_user>.+?)(?<userdir_uri>/.*)?$ {
alias /home/chroot/home/$userdir_user/public_html$userdir_uri;
index index.html index.htm index.php;
autoindex on;
include php5_generic;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
}
@brahimmachkouri
Copy link
Author

Debian 7.
This works for a chrooted user, which home is in /home/chroot. Look at the line number 8 in default file above.
php5_generic is in /etc/nginx/ : all the location of included files are relative to the default nginx configuration file folder (/etc/nginx in debian).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment