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 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?

share|improve this question

closed as off-topic by Seth Jun 28 at 22:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This describes a problem that can't be reproduced that seemingly went away on its own or was only relevant to a very specific period of time. It's off-topic as it's unlikely to help future readers." – Seth
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Try changing the permission of files under /var/www and check localhost/info.php –  devav2 Sep 5 '12 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 '12 at 14:52
    
okay got you :) –  devav2 Sep 5 '12 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 '12 at 2:42
    
Create the file info.php in /var/www/html/ instead of /var/www/. –  Akshay Sudheer May 21 at 10:47

2 Answers 2

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?

share|improve this answer

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.

share|improve this answer

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