I installed LAMP Server. I can access http://localhost
. I can also run successfully phpmyadmin. But when I go to http://localhost/testphp.php
, I get a 404 not found. The file is in /var/www/testphp.php. The file reads: <?php phpinfo(); ?>
. This information was taken from the guide: https://help.ubuntu.com/community/ApacheMySQLPHP. What am I doing wrong? Thanks in advance.
Asked
Active
Viewed 3.2k times
7

Guest123ABC
- 181
2 Answers
5
Most likely your file is not in the correct directory. Apache serves files from a directory referred to as the "Document Root". Your files must be in this directory for Apache to find them.
To check what the Apache is using as the Document Root:
- Open a terminal
- run
less /etc/apache2/sites-enabled/000-default
(may need sudo) - Look for the line the looks like
DocumentRoot /some/path
. Its towards the top - Make sure your php scripts are in
/some/path
This is assuming you haven't made any configuration changes to Apache. This can be much more complex if you have multiple virtual hosts, and aliases, and so forth. But for the default Apache configuration this will do the trick.

Dan
- 6,753
- 5
- 26
- 43
2
As like dan08 said, Apache serves files from the directory termed "Document Root". The default "Document Root" is /var/www/html
.
So, you have two options now.
- Either, Put your file into
/var/www/html
. - Or, Change "Document Root" with the help of dan08's answer. For your case, the DocumentRoot value should be
/var/www
.

Ramvignesh
- 1,812
- 6
- 20
- 31
/var/www/html
, not/var/www/
. See http://askubuntu.com/q/448944/158442 – muru Sep 04 '14 at 17:30