Public html directories for users

From XPUB & Lens-Based wiki
Revision as of 17:42, 23 March 2020 by Andre Castro (talk | contribs) (Created page with "=~= On shared servers users can be given public web folders often represented in the url as http://domain.nl/~username The following recipe will be explain how do it in a sa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

~

On shared servers users can be given public web folders often represented in the url as http://domain.nl/~username

The following recipe will be explain how do it in a safe way.

The recipe will use apache2 webserver, (TODO) ngnix config should be added

webserver configuration

apache2

Nginx

TODO

user public_html dir

Each user should have inside her home folder a dir called public_html, which can be done by a user with sudo powers.

Become super user (su)

sudo su - 

Create a public_html dir for each user making the user both owner and group

for u in `ls /home`; do mkdir /home/$u/public_html; chown $u:$u /home/$u/public_html; done 


==

#!/bin/sh

# make a new group
groupadd publicweb 
# add apache www-data group to it
usermod -a -G publicweb www-data 

# for each user in /home
for u in `ls /home`; 
do 
        echo $u; 
        # change group of user dir to publicweb
        chown $u:publicweb /home/$u
        # 
        chmod 751 /home/$u
        # 
        chmod 750 /home/$u/public_html
        #         
        chmod g+s /home/$u/public_html
        # 
        chgrp publicweb /home/$u/public_html
done