Public html directories for users: Difference between revisions
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...") |
Andre Castro (talk | contribs) No edit summary |
||
Line 34: | Line 34: | ||
for u in `ls /home`; | for u in `ls /home`; | ||
do | do | ||
echo $u | echo $u | ||
# add user to publicweb group | |||
usermod -a -G publicweb $u | |||
# change group of user dir to publicweb | # change group of user dir to publicweb | ||
chown $u:publicweb /home/$u | chown $u:publicweb /home/$u | ||
# | # give permissions rwxr-x--x others need to be x for apache transversing | ||
chmod 751 /home/$u | chmod 751 /home/$u | ||
# | # just allow read permission and traversal for the group, no write to public_html dir | ||
chmod 750 /home/$u/public_html | chmod 750 /home/$u/public_html | ||
# | # make the files created under public_html belong to publicweb group | ||
chmod g+s /home/$u/public_html | chmod g+s /home/$u/public_html | ||
# | # make group of public_html publicweb | ||
chgrp publicweb /home/$u/public_html | chgrp publicweb /home/$u/public_html | ||
done | done | ||
</source> | </source> |
Revision as of 16:51, 23 March 2020
~
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
# add user to publicweb group
usermod -a -G publicweb $u
# change group of user dir to publicweb
chown $u:publicweb /home/$u
# give permissions rwxr-x--x others need to be x for apache transversing
chmod 751 /home/$u
# just allow read permission and traversal for the group, no write to public_html dir
chmod 750 /home/$u/public_html
# make the files created under public_html belong to publicweb group
chmod g+s /home/$u/public_html
# make group of public_html publicweb
chgrp publicweb /home/$u/public_html
done