0

Just finish install ubuntu 16.04. After finish a fresh install of LAMP I got Error: Permission denied when try create a simple .php file to save into the localhost.

I have a idea but I can't figure out how to fix it.

As describe in many tutorials - install LAMP as SUDO... However, it's obvious I will have not access to this folder since I'm user "abc"

My steps: 1. sudo apt-get update 2. sudo apt-get install apache2 3. sudo apt-get install mysql-server 4. sudo mysql_secure_installation

I can see the Apache2 Ubuntu Default Page "Works"

Did I install wrong or I just need grant access as root for myself as user?

Any help is well appreciate.

  • 1
    Are you trying this on your own computer, or on a VPS or web hosting install ? If the latter, are you connecting and uploading through ftp, or sftp, or webdav or some other way ? By default apache2 uses /var/www/html or /var/www/ for the virtual hosts data to reside. For your normal user it would by default not be allowed to write in the /var/www/ directories. One solution to that is to use the apache2-mpm-itk package, and change your apache2 vhost config accordingly, as well as the file and dir ownership in the vhost in /var/www/ so that your normal user becomes owner. – albert j Jan 14 '17 at 03:35
  • Could you please add a little more detail? What exactly did you do, what did you want to achieve and what happened instead? Did you encounter any warning or error messages? Please reproduce them in their entirety in your question. You can select, copy and paste terminal content and most dialogue messages in Ubuntu. (see How do I ask a good question?) – David Foerster Jan 15 '17 at 22:26

1 Answers1

-1

You need to learn about the UNIX permission system and how to use chmod.

As a quick fix you could try

sudo chmod -R +rw /var/www/

This will add read and write permissons for all users to all the files (Recursively) in the folder /var/www (which I assume is the place you want to put your PHP files), but be careful when you do this stuff, you can mess up your system!

Alternatively, you could copy the files as root:

sudo cp ~/Documents/somefile.php /var/www

or create a file as root:

sudo gedit /var/www/somefile.php

Make sure you understand how the permission system of Ubuntu works as soon as possible if you are doing this for work rather than just for fun.