Mobile app version of vmapp.org
Login or Join
Bryan171

: Issues with Apache and loading PHP files [ubuntu] I just installed PHP and Apache2 on my laptop (ubuntu 12.04), but I can't get my PHP files to load. I have followed this tutorial: http://www.howtogeek.com/howto/ubuntu/inst

@Bryan171

Posted in: #Apache #Php #Ubuntu

I just installed PHP and Apache2 on my laptop (ubuntu 12.04), but I can't get my PHP files to load. I have followed this tutorial: www.howtogeek.com/howto/ubuntu/installing-php5-and-apache-on-ubuntu/ , and the index.html file works, but when I try any php, I get a server error.

I looked online for a few hours, and I added "AddType application/x-httpd-php .php" to my httpd.conf (but I don't think I'm supposed to be editing that file for the ubuntu version??) in /etc/apache2/, which somehow let ONE php file load (which just contains phpinfo()). I then tried making a new php file with the same code, but that one won't load (server error). I have no idea why it only loads that specific file. I have tried restarting apache and opening the other one first, but for some reason, it only loads the first file. I also tried to move the file to another directory in /var/www/, but not dice. I hope this makes sense, because I'm a beginner here. any help would be appreciated!!

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Bryan171

2 Comments

Sorted by latest first Latest Oldest Best

 

@Kevin317

Look in your Apache error log to see if there is a message. Often there's a typo or other error in the .php file that stops it from running.

In Ubuntu, the error log is in /var/log/apache2/error.log - you may need to sudo when trying to read it (in other words, sudo tail /var/log/apache2/error.log).

It's also possible you haven't given apache (the user www-data) access to the file - make sure the file can be read by that user.

If you've installed php5-cli you can also test the file locally, for example php mytest.php before trying it through the server. This will give you immediate feedback on the errors (the same errors, usually, that will appear in the Apache log).

10% popularity Vote Up Vote Down


 

@Radia820

You should not have to do a AddType in the httpd.conf as this should be added during the 'apt-get install php5' process.

It sounds like you have no enabled PHP5 and looking at that guide it does not mention a2enmod.

Please try: sudo a2enmod php5 then restart your Apache by doing a sudo /etc/init.d/apache2 restart or sudo service apache2 restart.

Other than that its hard to provide further insight without you editing your question and including more information such as the contents of your httpd.conf file. Please let me know if this works so I can delete this entry from the answer, or if it doesn't work edit your question and provide more details as mentioned.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme