0

(I am new to Ubuntu/Linux so please bear with me).

I installed apache 2 (version 2.4.18) on Ubuntu 16.04 LTS. I did this from a logged in user account using

sudo apt install apache2

Now, I am trying to replace the default index.html

However , I am unable to create or copy or move documents to

/var/www/html/

because I am not the owner of the folder I looked at the folder properties and it says the owner is root.

How do I change privileges so that I can use the apache server as if I (ie. the logged in user) had root-level privileges.

Thanks and happy new year.

  • 1
    use command sudo chown currentusername:currentusername /var/www/html – sanjeev Jan 2 '17 at 18:11
  • 1
    also you can do it by opening filemanager by root by issuing command sudo nautilus and after going into directory /var/www/ right click html folder and in properties you can change the owner – sanjeev Jan 2 '17 at 18:13
2

The default user for apache is www-data, so this is how I did mine:

  1. Add yourself to apache group www-data:

    sudo usermod -G www-data -a your_username
    
  2. Change /var/www/html ownership:

    sudo chown -R your_username:www-data /var/www/html
    
  3. Change the permissions on /var/www/html:

    sudo chmod -R 775 /var/www/html
    

This way both you and apache can work with the server documents in /var/www/html

1

use command sudo chown currentusername:currentusername /var/www/html

also you can do it by opening filemanager by root by issuing command sudo nautilus and after going into directory /var/www/ right click html folder and in properties you can change the owner

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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