avoid using sudo when working in /var/www



How to avoid using sudo when working in /var/www?




Answer  :

Add  the  user  to the www-data group and set the setgid bit on the /var/www directory so that all newly created files inherit this group as well.

sudo usermod -a -G www-data "$USER"

Correct previously created files (assuming you to be the only user of /var/www):

sudo chown -R "$USER":www-data /var/www
find /var/www -type f -exec chmod 0660 {} ;
sudo find /var/www -type d -exec chmod 2770 {} ;


sudo chgrp www-data -R /home/[YourHome]

Then by replacing /var/www by your own folder :

sudo mv /var/www /var/www.old;
sudo ln -s /home/[YourHome]/public_html /var/www;

Please shareShare on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Digg thisShare on StumbleUpon0Share on VKBuffer this page