3

I cannot save a php file in var/www/html and my computer shows error "Permission denied".

How to change permission to save file here?

muru
  • 197,895
  • 55
  • 485
  • 740

2 Answers2

8

You need to change the permissions for /var/www/html folder.

running this command will give everyone write access to the html fodder.

sudo chmod  o+w /var/www/html

The o stands for other and the + adds the permissions w is write.

Then you should be able to copy you're php file over to /var/www/html with out using Root permissions

If you want to learn more about the command chmod click on the link below.

FilePermissions

Neil
  • 4,475
  • 3
  • 22
  • 34
2

You need to change the permissions of that folder to gain access to write files. Here is the GUI method. Only use terminal to open Nautilus with root permisions. There is a risk opening Nautilus as root. Read it here.

  1. Open Terminal
  2. type sudo nautilus hit enter
  3. Navigate to the target file or folder you want to change permissions (/var/www)
  4. Right click the file or folder (html folder)
  5. Select Properties
  6. Click on the Permissions tab
  7. Click on the Access files in the Others section
  8. Select “Create and delete files”
  9. Click Change Permissions for Enclosed Files
  10. In the resulting window, Select Read and Write under Files and Create and delete files under Folders
  11. Click Change
  12. Click Close.
  • Using sudo nautilus is a bad idea. See http://askubuntu.com/questions/11760/what-is-the-difference-between-gksudo-nautilus-and-sudo-nautilus. – edwinksl Jun 26 '16 at 03:03