Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve /var/www copy/write permission denied?

Tags:

I am a newbie in php, mysql. I have written a hello.php script, which I am trying to copy into /var/www directory (and will later want to open it through web browser). The problem with the same is that I am not allowed to save/write any files in /var/www despite me being the root. I tried implementing steps in this question, but I get the following error when I process the third line

find /var/www/ -type f -exec chmod g+w '{}' ';'
chmod: changing permissions of `/var/www/index.html': Operation not permitted

I know symlink is also an option. I would want to be able to write/copy files directly to /var/www/ directory.

Any suggestions on what is going wrong?

like image 341
shubster Avatar asked Sep 27 '09 21:09

shubster


People also ask

How do I give permission to VAR www Ubuntu?

You state the permissions for /var/www are drwxr-xr-x which is rwx for owner only. Group has r-x which means even though you added yourself to the www-data group, the directory does not allow the group write permission to /var/www. chmod g+w /var/www to allow your account to be able to add files to /var/www.

How do I get rid of Permission denied in Linux?

To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode) command for this purpose.


3 Answers

it'matter of *unix permissions, gain root acces, for example by typing

sudo su
[then type your password]

and try to do what you have to do

like image 100
Lopoc Avatar answered Oct 19 '22 11:10

Lopoc


Do you have a file in /var/www called hello.php already that has permissions on it? Maybe the system can't replace the file?

Although, root access should supersede any user on the system.

Have you tried applying permissions to the www folder?

If you can do this, try the following:

sudo chmod -R 777 /var/www

then do:

sudo cp hello.php /var/www

I only recommend doing this if you know 100% that it is ok to set permissions on the whole www folder. By the sounds of it, you are running on your own production server as most live/shared hosting servers are setup so that the www folder is not in the /var folder (instead it is in the home folder of the user).

Be VERY careful when doing anything with the sudo prefix though, you can seriously damage your system if you do it wrong.

like image 41
Tisch Avatar answered Oct 19 '22 12:10

Tisch


Are you in a development environment ? If Yes, You can do

chown -R user:group /var/www

so you will be able to write with your user.

like image 43
Gabriel Sosa Avatar answered Oct 19 '22 13:10

Gabriel Sosa