3

I have been following this tutorial

http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-ubuntu-12.04-lts-lamp

And I have got to the part where I am running a simple test to determine whether php has been installed properly

the installation went fine, I installed php5 using the following command apt-get install php5 libapache2-mod-php5 and I then restarted the server.

to see whether php5 has been installed I did the following

created a file vi /var/www/info.php

edited the file <?php phpinfo(); ?>

after trying to run it on my server I get a 404 Not Found error. What could be the problem?

6
  • Try changing the permission of files under /var/www and check localhost/info.php
    – devav2
    Sep 5, 2012 at 14:50
  • @devav2 Im not running the server on my computer I can't use local host, but I'll look into changing permissions
    – mk_89
    Sep 5, 2012 at 14:52
  • okay got you :)
    – devav2
    Sep 5, 2012 at 14:54
  • If the apache place holder worked for you but the php info did not try sudo chown -R www-data:www-data /var/www
    – damien
    Sep 6, 2012 at 2:42
  • 1
    Create the file info.php in /var/www/html/ instead of /var/www/.
    – user283810
    May 21, 2014 at 10:47

2 Answers 2

2

First check your Ubuntu Version.

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"

Restarting apache services will solved your problem.

sudo service apache2 restart

If you are getting Ubuntu 14.04 LTS

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=Trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

Then your apache root directory will be /var/www/html/

 sudo vim /var/www/html/info.php

<?php
phpinfo();
?>

write your php script.

Restart apache2 service.

sudo service apache2 restart

Try it.

0

If it is a permission problem it should return 403, not 404. Check the files in /etc/apache2/sites-enabled/ . There is probably only one file (000-default) if you didn't create any new hostnames yourself. Does it say 'DocumentRoot /var/www' ? And does it say:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>`

Somewhere?

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