CentOS 6
Sponsored Link

Nginx - Enable UserDir
2013/07/07
 
Configure Nginx that Users can open their site in the home directories.
[1] Configure Nginx
[root@www ~]#
vi /etc/nginx/conf.d/default.conf
server {
    listen       80 default_server;
    server_name  www.srv.world;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
   
# add follows in "server" section

    location ~ ^/~(.+?)(/.*)?$ {
        alias /home/$1/public_html$2;
        index  index.html index.htm;
        autoindex on;
    }
}
[root@www ~]#
/etc/rc.d/init.d/nginx restart

Stopping nginx: [ OK ]
Starting nginx: [ OK ]
[2] Create a HTML test page with a common user and make sure it works or not. It's OK if the following page is shown.
[cent@www ~]$
chmod 711 /home/cent

[cent@www ~]$
mkdir ./public_html

[cent@www ~]$
chmod 755 ./public_html

[cent@www ~]$
vi ./public_html/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Nginx UserDir Test Page
</div>
</body>
</html>
Matched Content
 
Tweet