Set Permissions to add files to /var/www folder in ubuntu linux

/var/www is the default root folder of your local web server (like apache), you host all your website files here and access it on the browser with url like http://127.0.0.1 or http://localhost

you cannot simply copy paste stuff in this folder using your file browser, It is protected for security reasons, you will get a permission denied error message because by default you don’t have write access permission here.


Follow these Steps:

execute these commands to set all permissions for /var/www directory

sudo adduser <username> www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rwX /var/www

replace <username> with your actual username.

Now you can copy, edit and create files in /var/www folder just like any other folder.

Leave a Reply

Your email address will not be published.