View Full Version : php not working on 8.04
July 27th, 2008, 09:41 PM
So I have apache2, libapache2-mod-php5, php5 installed on my system. I am trying to do PHP development and then I will try to open my files on Firefox and I get nothing. This the code I entered:
<title>Look Out World</title>
<?php echo "Hello, world!" ?>
and when I open it in firefox as an html, it's blank. If I do it as a php, it asks me to download it. sudo a2emod says that php5 is loaded. I am not sure what's wrong. Any ideas?
July 27th, 2008, 11:35 PM
Have you place your php file in the directory /var/www/
You should go to http://localhost/
and your php files will appear there.
And if you the installation is missing
read the guide here (http://ubuntuguide.org/wiki/Ubuntu:Hardy#Install_a_LAMP_server_on_a_Desktop).
July 27th, 2008, 11:49 PM
did it work in previous versions? or is this your first time with the OS?
when i first switched to ubuntu, i made the mistake assuming my php scripts would work anywhere. Put them in /var/www/. Another mistake i made was double clicking them there - i would get the same result/prompt. go to brower and type in: localhost
July 27th, 2008, 11:52 PM
You cant run your php scripts from any location, because not every directory on your computer is affected by the server.
You must put your php script in servers directory, im not sure which it is in your case because I use lampp, in my case it's /opt/lampp/htdocs.
In your case it could be /var/www but I'm really not sure, try it.
July 28th, 2008, 01:53 AM
i see. makes sense. This is the first time I've done PHP development on this system. I guess I need to move stuff to the server portion. Any other possible issues?
July 28th, 2008, 02:16 AM
Hey, i just moved it to my server and php is not workig still. LAMP is installed. Any ideas?
July 28th, 2008, 02:48 AM
make sure the apache config knows about the php type (search google for "addtype php", you should get something). Also for the root directory, you might want to enable ExecCGI option.
July 28th, 2008, 05:21 AM
So how do I do the ExecCGI thing?
July 28th, 2008, 06:07 AM
try google and apache docs :)
July 28th, 2008, 06:44 AM
I might be able to help. I'm running Gutsy, but I just spent a good part of the afternoon getting this to work.
I'll just copy in my configuration file:
LoadModule php5_module "/usr/lib/apache2/modules/libphp5.so"
AddType application/x-httpd-php .php
In fact, here's a link you can use to just download the whole site:
Just unzip it in your desktop, replace all instances of "ceclauson" in conf/httpd.conf with your username, and you should be good. Run the start.sh and stop.sh scripts in the terminal to start and stop the server.
(P.S., Even though I know I'm trustworthy, you don't. You probably want to check these scripts first to make sure they don't contain malicious commands)
July 28th, 2008, 02:19 PM
Cool, I'll try it. My httpd.conf file is empty, do you guys mean apache2.conf or do I have something screwed up pretty bad?
July 29th, 2008, 04:05 AM
To the best of my knowledge, Apache always looks for a file called httpd.conf for the configuration.
July 29th, 2008, 06:18 AM
Ubuntu's Apache conf is in /etc/apache2/apache2.conf. You can ignore httpd.conf--it's only there for compatibility. Also, if you installed via the normal Ubuntu packages, I can guarantee that the default configuration works--no need to mess with it. Your problem is something else. Have you looked in Apache's logs? Have you examined the response headers?
If you have messed with Apache's configuration, the only relevant lines from ceclauson's config are the LoadModule and AddType lines--both of which should be in /etc/apache2/mods-enabled/php5.*
Also, there's no need to enable ExecCGI if you're using the PHP Apache module, which doesn't use CGI.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.