1

I've installed the LAMP stack on my Ubuntu 14.04 laptop using the command:

sudo apt-get install apache2

I went to localhost and it shows the typical tree (Index of ... https://i.stack.imgur.com/DPc8A.png in my case the tree is empty).

So I type at the command line sudo service apache2 start

After that I create a hello world php file, called example.php

And then I put that file inside var/www folder (to getto that folder I go to files and then to system, and then to var folder, and then to www folder).

And finally I open my browser and type localhost/example.php

The file appears as not found.

Note: From the console I've done this also: sudo chmod -R 755 var/www I've also checked www folder perms and anybody has access files and I have "create and delete files" permission.

What should I do? The files are there but localhost show an empty list and Any file is "not found" when I try to acess it from the browser.

3
  • 1
    Aside from the DocumentRoot issue, apt-get install apache2 only installs apache2 surely? To get the full LAMP stack you would need sudo apt-get install lamp-server^ or equivalent. Jul 23, 2014 at 0:16
  • Thanks for linking to that discussion. Haven't read it. But I don't think it's a duplicate because of how the question is set. I mean the result IS the same (the folder is html after all), but I didn't quite realize it, and I thought it was an installation issue. Anyway, if several people think it's a duplicate, I'll most certainly remove it.
    – Rosamunda
    Jul 23, 2014 at 0:17
  • Thanks @steeldriver haven't realize that! Maybe that's why php wasn't working even after moving the files to the /html folder... :)
    – Rosamunda
    Jul 23, 2014 at 0:27

1 Answer 1

6

In Ubuntu 14.04 the default DocumentRoot is /var/www/html/ instead of /var/www/.

You can change this in /etc/apache2/sites-enabled/000-default.conf (but is usually better to keep it it like this).

1
  • Thanks! Didn't know that (why they would do that, anyway?). The folder wasn't accessible, so I've: sudo chown 'myusername.users /var/www/html'
    – Rosamunda
    Jul 23, 2014 at 0:18

Not the answer you're looking for? Browse other questions tagged .