How do I administer /var/www?
That is a protected folder. You need to be root in order to modify this directory.
You can also make gab the owner of this directory by doing
sudo chown -R gab /var/www
sudo
will execute the chown -R gab /var/www
command as a root (administrator) and prompt you for your password used when setting up the system (most likely the same password as gab).
Once you do this, you can also do
sudo chown -R 755 /var/www
to give write permissions.
# Permission
7 full
6 read and write
5 read and execute
4 read only
3 write and execute
2 write only
1 execute only
0 none
Reference Class Description
u user the owner of the file
g group users who are members of the file's group
o others users who are not the owner of the file or members of the group
The 755 means that the user will have full access, group will have read and execute access and others will have read and execute access.
I was going to suggest you become a member of the www-data
(or equivalent) group, but since the directory and the index.html
file are both owned by root
, you may indeed be expected to do so (as kobaltz suggested)—if you want to avoid Virtual Hosts.
If you go the way of Virtual Hosts, the /var/www
directory is merely a placeholder that allows you to verify that Apache is running.
I know it's a bit of a read, but did you have a look at this documentation page or this wiki page?
Actually the files should be owned by www-data (or www-data should have write privileges). The 'lazy' way is to use sudo to switch yourself to root and chown the files to yourself, do what you need to do, then switch it back to www-data - i think these files were added using sudo, but whoever did it did not give ownership over to www-data
The right way is to set the folder to be group writable, and to add yourself to said group. This of course makes more sense since you only have to do it once (for the www-data directory), and you can work with your regular user after that. Kobaltz has the right basic idea, but some aspects of execution seem incorrect to me.