Apache and User Permissions on RHEL
June 6th, 2007 by Anthony Curreri
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 the ownership by username apache and group webauthors:
sudo chown -R apache: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
If you found this helpful, help me by checking out the ads at the bottom of the page. Thank you!
Bookmark with: | del.icio.us | Digg it | Netscape | Newsvine | Yahoo MyWeb |
Leave a Reply
You must be logged in to post a comment.
