avoid using sudo when working in /var/www

by
Share this Article: Facebook0Google+0Twitter0LinkedIn0Reddit0StumbleUpon0

Question

 

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 {} ;



OR

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;



For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter0LinkedIn0Reddit0StumbleUpon0