Step 1 :- Create a new group (www-pub) and yourself to that group
sudo groupadd www-pub
sudo usermod -a -G www-pub usera
sudo usermod -a -G www-pub usera
Here "usera" is your user name. You must use -a to append to existing groups
Now display groups for a user (optional)
sudo groups usera
Step 2 :- Change the ownership of everything under /var/www to root:www-pub
sudo chown -R root:www-pub /var/www
Step 3 :- Change the permissions of all the folders to 2775
sudo chmod 2775 /var/www
2=set group id, 7=rwx for owner (root), 7=rwx for group (www-pub), 5=rx for world (including apache www-data user)
Set group ID (SETGID) bit (2) causes the group (www-pub) to be copied to all new files/folders created in that folder. Other options are SETUID (4) to copy the user id, and STICKY (1) which I think lets only the owner delete files.
Step 4:- There's a -R recursive option, but that won't discriminate between files and folders, so you have to use find, like
sudo find /var/www -type d -exec chmod 2775 {} \;
Step 5 :- Change all the files to 0664
sudo find /var/www -type f -exec chmod 0664 {} \;
And now we are done. Now we can easily create and edit files in the www folder and all of its sub folders.
yet i did create the folder in that please help me
ReplyDelete