Skip to content

Instantly share code, notes, and snippets.

@vandorjw
Created October 17, 2013 21:27
Show Gist options
  • Save vandorjw/7032471 to your computer and use it in GitHub Desktop.
Save vandorjw/7032471 to your computer and use it in GitHub Desktop.
Reset the permissions on /var/www/
###DO NOT USE AS IS, please read the comments###
# Debian based systems
chown -R www-data:dev-ops /var/www/
chmod -R u+rX-w,g+rwX,o-rwx /var/www/
# RHEL based
chown -R apache:dev-ops /var/www/
chmod -R u+rX-w,g+rwX,o-rwx /var/www/
@vandorjw
Copy link
Author

In the apache config, we always set a user and group which httpd will run as. Running as root is dangerous.

Checking the apache configuration will give you the user it runs at. I also like to create a group for all the members working on a webprojects. I call this group "dev-ops"

You can create this group by running:

(sh) # groupadd dev-ops

Then add the users you want to be part of that group using

(sh) # usermod -G dev-ops -a user_name

To check which groups your currently running user is already a part of type

(sh) $ groups

The two commands on in the gist will set the owner of each file and directory to the user apache runs as, and sets the group to dev-ops. It then gives the owner read permission (and execute if it is a folder, hence "capital" X).
The dev-op group will have read, write permission, (and execute on folders so we can open them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment