-1

I have a dedicated server but only root can access my hosting directory. All other users get permission denied when I try access the directory with another user.

I have created a new user, added the user to the apache group (as the directory is owned by apache)

# usermod -a -G apache newuser

Also tried

# usermod -g apache newuser

Yes, I have relogged in and restarted SSHD

I have set permissions to 775 but not recursively as I am running Magento.

drwxrwxr-x+ 8 apache apache      4096 Apr  7 21:52 website

I also tried to use Access Control Lists, like below

setfacl -m u:user:rw /var/www/html/website

# file: website
# owner: apache
# group: apache
user::rwx
user:user:rw-
user:userb:rw-
group::r-x
mask::rwx
other::r-x
DaleZA
  • 31
  • 4

2 Answers2

2

In case someone has a similar problem, this is what I did. I hope it's the correct approach but I am not sure.

The + in the permissions

drwxrwxr-x+ 

indicates that there is an access control list in effect on the directory.

I changed the permissions recursively for ACL as per below as well as included execution permission for the user.

setfacl -Rm u:user:rwx /var/www/html/website
DaleZA
  • 31
  • 4
-1

Enter top

Then watch the httpd process. On the very left in the USER column it should say something like 'nobody' or 'www-userdata' or similar. Remember it.

Then change to your home directory e.g. /home/myuser/public_html.

Run

cd /home/myuser/

Run

chown -R nobody:nobody public_html (replace nobody:nobody if different user runs apache process)

Depending on your PHP handler (suPHP) you may have to:

Run chown user:nobody public_html on the directory, where user is the name of user the directory belongs to.

Just to be sure, verify that files are chmodded 644 and directories 750/750. The public_html should be 750, not 775

If you issue 775 on anything you are exposing yourself and give read and execution permissions to outsiders who will exploit your server. They may not be able to write files but if they use a buffer-overflow exploit and gain access they dont have to and can execute files on your server.

mashup
  • 330
  • 1
  • 11
  • Ran the following find find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; instead of top I did ps aux | egrep '(apache|httpd)' and it shows user as apach. Is this correct – DaleZA Apr 14 '15 at 20:23