1

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

I have install PHP from this article on my ubuntu computer

http://www.howtogeek.com/howto/ubuntu/installing-php5-and-apache-on-ubuntu/

now when I tried to save a simply php file I am unable to do that. I have no access to that folder var/www

$ chmod +x /var

chmod: changing permissions of `/var': Operation not permitted

I am not sure what this command do. can someone let me know how to get it worked then I can save file from any software I use.

I just have install php and it's work fine and this post is about giving 'var/www' permission that I can save the file their.

Thanks


Now after a restart my computer I got my permission worked.

4 Answers4

6

If you are using it for development just change the owner of /var/www folder to your username.

sudo chown username:username -R /var/www

make sure to change the "username" word from the above command to yours.

2

Since the directory is owned by root, you will not be able save a php file with any editor without running with gksu as root. So, I suggest two simple ways to fix this:

sudo cp /path/to/file.php /var/www/

(or)

Run the editor as root using gksu and save the file at /var/www/

Also, for a glitch free execution of the php file, make sure the file has 755 permissions. Hope I've been of some help. :)

l0n3sh4rk
  • 444
0

The command sudo chmod +x /var is used to add/remove permissions to/from the specified file/folder.

  • parameter + used to add permissions
  • parameter - used to remove permissions
  • parameter r mean read permission, w is write and x is execute.

Example:

sudo chmod -r -w +x /var/www

remove read permission, remove write permission and give execute permission to /var/www folder for all users and group.

You can simply run gksu nautilus and go to the /var/www directory, then right-click on it. Choose Properties, then go to the permission tab where you can change permissions of that folder/file.

Lekensteyn
  • 178,446
user64786
  • 19
  • 2
-1

The folder /var/www needs root permission to change its rights. Why not try:

sudo chmod +x /var

If that is not working for you, then try to modify only the www folder which seems to be of special interest to you, like this:

sudo chmod 777 /var/www

Hope that helped.

NlightNFotis
  • 2,510
  • 1
  • 17
  • 26