Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the ownership (chown) from 'root' to 'apache'

System OS: CentOS7.0-64 LAMP for VSI

Problem: I am attempting to change the ownership of two virtual directories from 'root' to 'apache', so that Apache can read and write data. I am using the following commands but to no avail.

 chown -R apache:apache /var/www/html/www.example-virtualhost1.com
 chown -R apache:apache /var/www/html/www.example-virtualhost2.com

When entering these commands I am receiving an error 'command not found.' Any reference material would be greatly appreciated.

Best.

like image 344
Christopher lee Avatar asked Jan 05 '23 12:01

Christopher lee


1 Answers

In order to change the ownership, try the following line:

sudo chown -R apache /var/www/html/

or

sudo chown apache /var/www/html/www.example-virtualhost1.com

The structure is as follows please note the parentheses as an attempt to explain each piece of the command:

sudo(run the command as root) chown(command to change ownership) -R(recursively change everything within the folder) apache(who you want to be the new owner) /var/www/html/(the folder you would like to modify ownership)

Once you have ran this command, you should be able to type in the following command:

ls -lr 

That command will show you who has ownership.

I hope this helps!

like image 85
rishikarri Avatar answered Jan 13 '23 12:01

rishikarri