Search code examples
mysqlpermissionsapache2lampubuntu-18.04

Permission denied inside /var/www/html when creating a website and it's files with the apache2 server


screenshot from inside atom UPDATE** The screenshot is within atom, but when I navigate to the directory using the file explorer, and right click, the option to rename or create a new folder are restricted and I cannot click on them.

I just finished setting up the LAMP stack on my fresh UBUNTU 18.04 installation. I have everything working, the default /var/www/html/index.html page from Apache2 is being served on localhost, no port forwarding or any unique domain name, i just wanna run this on my network from my computer for now.

If there is a simple way to create multiple websites and easily choose which folder to serve than that's fine, but I want to serve just one website for now.

When I go to my /var/www/html folder and try to edit the index.html file it says permission denied. What do I need to do in order to work inside this directory for the remaining time that I am building the website. I am signed in as the root user on my system.

Also, if I do change permissions to allow me to work in this directory, what does it mean for people trying to access my server if it was available to the public. (RIGHT NOW JUST ON LOCALHOST).

Lemme know if you need more info or explanation thanks!


Solution

  • sudo chown -R $USER:$USER /var/www
    

    this works, it changes the owner to my user instead of root user. I still don't understand because my user already had sudo rights and all those permissions. It was the user I created during the ubuntu18.04 setup, so there shouldn't be an issue, or idk.