When you have executed chown commands, you did next: at first you've changed the owner of /var/www/html
to ec2-user
, and with next command you've changed the owner and owner group to apache. You can set only one pair of owner:owner-group to file or directory or whatever.
You have at least two ways to solve your task:
usermod -a -G apache ec2-user
- this will add user ec2-user
to apache
group, after that, make sure, that permissions allows apache
group members to manipulate files and directories as you need.
- Create a subdirectory in
/var/www/html
with owner set to ec2-user
and group set to main apache
group and make sure that Apache could access it. You can configure it as a VirtualHost to separate it from original DocumentRoot.
Also, you have to set ec2-user
home directory to /var/www/html
, because even if it's has rights to access /var/www/html
, it isn't necessary that it can access /var
or /var/www
.