server { | |
listen 80; | |
server_name localhost; | |
# ... other default site stuff, document root, etc. ... | |
location ~ ^/~(?<userdir_user>.+?)(?<userdir_uri>/.*)?$ { | |
alias /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; | |
} |
This comment has been minimized.
This comment has been minimized.
Thank you guy! |
This comment has been minimized.
This comment has been minimized.
Really helpful. Thanks. |
This comment has been minimized.
This comment has been minimized.
This was very good example. However, I think this example doesn't set PATH_INFO correctly as in http://wiki.nginx.org/PHPFcgiExample. I did modifications for the regexp to match https://server.com/user/username/ userdirs: default.conf location ~^/user/(?<userdir_user>.+?)(?<userdir_uri>/.*)?$ {
alias /home/$userdir_user/www$userdir_uri;
index index.html index.htm index.php;
autoindex on;
include php5_userdirs;
} (This has to be before the location / rule) Now for example
saves
and php5_userdirs
and now SCRIPT_FILENAME, SCRIPT_NAME, PATH_INFO, REQUEST_URI, DOCUMENT_URI and DOCUMENT_ROOT variables seem to be like in nginx documentation example. I have no idea if this is correct and I need to run more tests. It's still missing one part of the NGINX guide:
Can someone confirm if my findings are correct? |
This comment has been minimized.
This comment has been minimized.
Here's what I'm doing for PHP + userdirs in Amend default.conf:
Add php5_common:
Some notes:
|
This comment has been minimized.
This comment has been minimized.
@alanorth Thanks! I added that to my nginx config (with a minor adjustment; the socket on Debian is |
This comment has been minimized.
This comment has been minimized.
The php5_generic cannot be included directly, it should be in a separate file. Otherwise it won't work. |
This comment has been minimized.
This comment has been minimized.
Could this be modified to work with Gunicorn does anyone know? |
This comment has been minimized.
This comment has been minimized.
@alanorth @nyuszika7h I too was able to use this on Ubuntu 18.04 by updating just the socket reference. |
This comment has been minimized.
Used to setup user directories on my personal server. Works brilliantly. Saved me a lot of time and stress. Thanks.