Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

User Home Dirs

$
0
0
I am trying to configure nginx so that when going to `http://example.com/~user/` it will load files from the `/home/~user/www/` directory.

I have found a script that seems to work for .html files but returns 404 errors on .php files. I think it has to do with the `~\.php` block in my conf file but am not really sure how to resolve.

Here is my default.conf file:

//nginx config

server {
listen 80;
server_name example.com;

root /home/example.com/www;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/example.com/web;
}

/////
//user home directory code

location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/www$2;
autoindex on;
index index.php index.html
}

////

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>