LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-29-2008, 08:55 PM   #1
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
php5 not working correctly with apache2


On Kubuntu 8

This does not work-
Code:
<?php
phpinfo();
?>
This DOES work-
Code:
#!/usr/bin/php
<?php
  print "Content-type: text/html\n\n";
  phpinfo();
?>
To me it looks like something about my apache install/config is wrong concerning php5.

Please advise.

Thanks,

Steve
 
Old 10-29-2008, 09:05 PM   #2
wernerz
Member
 
Registered: Jun 2008
Location: Ottawa, Ontario, Canada
Distribution: debian, dsl-n
Posts: 55

Rep: Reputation: 15
Sounds like you installed php5-cgi. To enable php cgi, you need to add a handler for it in the apache default config file. Here is an example:

<IfModule mod_mime.c>
AddType application/x-tar .tgz
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
ScriptAlias /php /usr/bin/php
Action php /php
AddHandler php .php
</IfModule>

OR install the apache2 php module. Use apt, aptitude or synaptic and search for libapache2-mod-php5
 
Old 10-29-2008, 09:14 PM   #3
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
Thanks for the quick response!

In my frustration I blew away my whole install and started from scratch:
Code:
apt-get remove apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql
I then re-installed apache & php (and mysql):
Code:
apt-get instal apache2 php5-mysql libapache2-mod-php5 mysql-server
I am still getting a "500 Internal Server Error";

From apache's error.log:
Code:
[Wed Oct 29 19:09:33 2008] [error] [client 127.0.0.1] (8)Exec format error: exec of '/var/www/phptest.php' failed
[Wed Oct 29 19:09:33 2008] [error] [client 127.0.0.1] Premature end of script headers: phptest.php
 
Old 10-29-2008, 09:26 PM   #4
wernerz
Member
 
Registered: Jun 2008
Location: Ottawa, Ontario, Canada
Distribution: debian, dsl-n
Posts: 55

Rep: Reputation: 15
Is the test file executable? chmod 755 phptest.php ?? Also make sure there are no extra spaces in the file:

Code:
<?php
phpinfo();
?>
<-- No space here

Last edited by wernerz; 10-29-2008 at 09:28 PM.
 
Old 10-29-2008, 09:38 PM   #5
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
SOLVED!!!

I found in my /etc/apaches2/sites-enabled/000-default the line
Code:
AddHandler cgi-script .cgi .php .py
Removed it, restarted, and all is once again right with the world!

Thanks and cheers,

Steve
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2 and PHP5 no longer working tensigh Linux - Server 14 01-08-2008 06:30 PM
php5 not working with apache2 in debian 4.0 mohtasham1983 Linux - Server 2 08-08-2007 09:19 PM
Apache2 and php5 not working RestInPieces Fedora 2 06-27-2006 06:27 PM
php5 not working on apache2 akp913 Debian 1 06-26-2006 03:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration