0

I have installed and configured apache on RedHat 7 Image on AWS. But I have issues with permissions/ownership while uploading files by ssh using filezilla.

I Setup a ssh user and added its home dir to apache /var/www/html/ and installed Magento on it.

Original Setup:

  1. User:Group of /var/www/html/ is apache
  2. User: root / Group: apache for /var/lib/php/session dir(not sure but I think magento stores session files there as well as i get write error when owner is changed)
  3. httpd.conf User:Group is apache
  4. With these settings, cannot upload files with ftp or sftp - permission error.

When I changed to:

  1. User:Group of /var/www/html/ is ssh_user
  2. User: ssh_user / Group: ssh_user for /var/lib/php/session dir
  3. httpd.conf User:Group is ssh_user
  4. With these, i was able to upload but cache files are generated as root.

What I want is:

  1. User:Group of /var/www/html/ is ssh_user
  2. Default settings for /var/lib/php/session dir
  3. httpd.conf User:Group is apache

I want to be able to upload files through ftp or sftp by regular user.

How do i acheive this? This is the first time i have setup apache so just trying to learn how to do it right way.

0

Please check your apache httpd.conf. There you can see ServerRoot and ServerAdmin as well. There, you will be having:

ServerRoot "/etc/httpd"
ServerAdmin root@localhost

Access permissions to server installation or configuration must be root as shown above and not suggested to modify.

But, For docroot location which usually /var/www/html, User and group will be apache. It can be changed to any other user except root. It is important to change the owner for docroot or DocumentRoot directory location which is /var/www/ or /var/www/html with either apache or any other not root user. You can change it to user of your choice. root is not suggested to set as user and group in httpd.conf

User apache
Group apache

make sure you must change the owner of docroot directory with the same user as mentioned in httpd.conf.By default the user and group are apache. So, you will need to change the owner of docroot directory /var/www/html to apache as shown below:

sudo chown -vR apache. /var/www/html

Now your website pages will start to create cache whenever you visit a webpage loaded by apache.

In your scenario, As you are using and ssh_user as user, You can set User:Group your desired directory location and all its internal hierarchy, for.eg., for the path /var/www/html/, then you can make it with below command.

Syntax: sudo chown -vR username:groupname {path-of-directory-location}

sudo chown -vR ssh_user:ssh_user /var/www/html
sudo chown -vR apache:apache /var/lib/php/session

If you want to be able to upload or transfer files through ftp or sftp by regular user., You can use any of either FileZilla Server or WinSCP, it is suggested to login with the user owning the directory and then transfer the files.

Make sure if you have either user or group permissions to the directory you are trying to access.

  • The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost? – Syed Mudabbir Apr 18 '17 at 20:45
  • @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper – Srikanth Popuri Apr 18 '17 at 20:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.