Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently installed Ubuntu 14.04, then I installed lamp-server and placed my webpages in /var/www directory, but when I opened localhost in the browser there was nothing. I think that happened because Zend updated Apache.

Whatever the reason may be, I want to know where to keep my php files so that I can access them from my browser.

share|improve this question

2 Answers 2

up vote 27 down vote accepted

The apache2 version that was published when the Ubuntu 14.04 release was made is 2.4.7 and starting with this version it seems that, for security reasons, the new root directory for the server is:

/var/www/html

So, from now, here you must to place the files for your (local) website. And like this you should not have this problem again with the future updates.


Anyway, if you want to change this directory with another one, you have to modify (as root) the following line from /etc/apache2/sites-available/000-default.conf file (sudo nano /etc/apache2/sites-available/000-default.conf):

DocumentRoot /var/www/html

to

DocumentRoot /path/to/another/directory

After these, to take effect the new changes , you must to restart apache server using the following command:

sudo service apache2 restart
share|improve this answer
7  
Interesting, I tried searching for the reasoning behind this move. If anyone is interested I found this bug report in Debian which explains it. –  Dan Apr 17 at 9:53
    
Thanks for this. –  Orangeman555 Apr 23 at 20:11

While the other answers work, I disagree with their solution.

Instead of modifying /etc/apache2/sites-available/000-default.conf back to the old version, I prefer keeping default package files unmodified.

A reason for this is that so it wouldn't break during the next upgrade again which might reset the 000-default.conf file.
Besides, such modifications are not done just to annoy us, the modification was done for a good reason, as this bug report in Debian explains.

Our webservers set the default document root to /var/www, whereas site-local administrators tend to use /var/www/example.com. This has security implications if visitors access the default document root, bypassing the /supposed/ document root of example.com. That's problematic if sensitive data is placeѕ outside the supposed document root (e.g. consider a hypothetical /var/www/example-com-db.conf configuration file).

A better solution would be to move the sites files from /var/www to /var/www/html/.

# 1. move all files excluding the `html` directory
sudo mv /var/www/[!html]* /var/www/html
# 2. Move the hidden files as well which are skipped in previous command
sudo mv /var/www/.[!.]?* /var/www/html/

Also another possible solution, is to create another Virtual Host and disable the default on with sudo a2dissite 000-default

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.