Mail Beyond Logo
Posts
Comments

You have a webserver, and you want several users to be able to log in and edit files in the /var/www/html directory. Here’s some handy commands.

After copying new files to the directory, try this command to fix up the permissions.

sudo /sbin/restorecon -R -v /var/www/html

You want all your web authoring users to be in the same group. Create a new group with:

sudo /usr/sbin/groupadd webauthors

Add users with that group using:

sudo /usr/sbin/useradd -g webauthors newusername

Then set that users password:

sudo /usr/bin/passwd newusername

To change an old users group:

sudo /usr/sbin/usermod -g webauthors existingusername

Now give all the web files ownership by proper username and group:

sudo chown -R staff:webauthors /var/www/html/ (for the root dir)
sudo chown -R staff:webauthors /var/www/html/.design (don’t forget any dirs beginning with .)
sudo chown -R staff:webauthors /var/www/html/*

Now set the permissions on the web files so that the owner, and the group can edit them.

sudo chmod -R 775 /var/www/html

It’s also probably a good idea to change the group Apache user to webauthors, in case someone uploads a file, because then they will be the owner.

sudo vi /etc/httpd/conf/httpd.conf (change ‘Group’ entry)
sudo /usr/sbin/usermod -g webauthors apache

If you found this helpful, help me by checking out the ads on the right. Thank you!


Link to this post! Copy and paste this code into your blog or website:
<a href="http://www.mailbeyond.com/apache-and-user-permissions-on-rhel"> Apache and User Permissions on RHEL </a>

Leave a Reply