1

I am trying to add a LAMP Web Server by following the instructions at "http://www.howtogeek.com/howto/42480/how-to-turn-your-home-ubuntu-pc-into-a-lamp-web-server/"

I ran the following command:

sudo apt-get install lamp-server^

Everything seemed to install okay.

Testing of Apache worked fine using the localhost check

Next, I tried to test PHP by creating the file

sudo nano /var/www/testing.php
  <?php phpinfo(); ?>  

I checked to make sure the file is located in the following directory:

Root/var/www/testing.php

I then restarted Apache with the following command:

sudo service apache2 restart

Next I tried to load the following page in my web browser:

http://localhost/testing.php

I receive the following error message:

Not Found - The requested URL /testing.php was not found on this server. - Apache/2.4.18 (Ubuntu) Server at localhost Port 80

I checked to make sure PHP installed correctly using the following command:

~$ php --version

Which returned:

PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
  with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by    Zend Technologies

Any ideas why I can not access testing php file, and why I am getting the 404 not found error message?

  • Which is the directory DocumentRoot set in your 000-default.conf? – pa4080 Feb 13 '17 at 7:23
  • Move the file from /var/www/testing.php to /var/www/html/testing.php and try again – Parto Feb 14 '17 at 9:15
2

Check DocumentRoot in

/etc/apache2/sites-available/000-default.conf

and

/etc/apache2/sites-available/default-ssl.conf
  • Both documents are found in the root/etc/apache2/sites-available/ directory? – Craig Timmreck Feb 12 '17 at 16:38
  • Look what you have in /etc/apache2 – Emilio Galarraga Feb 12 '17 at 16:53
  • I have in /etc/apache2 apache2.conf envvars magic ports.conf – Craig Timmreck Feb 12 '17 at 17:17
0

Changing the DocumentRoot to /var/www in the following configuration files solved the problem.

/etc/apache2/sites-available/000-default.conf

and

/etc/apache2/sites-available/default-ssl.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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