LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 07-18-2007, 07:22 PM   #1
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
apache2 displays PHP source instead of evaluating


When i browse a php page under my Apache server the php source is displayed, instead of its output.

I've seen this before, typically the php module isn't being loaded.

I am new to VirtualHosts. I have not added anything within my virtual hosts tags having to do with php, I assume that if its not defined in the virtual host it will use the global setting.

My /etc/httpd/conf.d/php.conf file looks as follows:
Code:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
AddType text/html .php
DirectoryIndex index.php
the module is present @ modules/libphp5.so


my sample page:
Code:
<?php
 //filename: index.php
 print "hello world.";
?>
Apache's log/error_log does not report any warnings or errors

Last edited by Hewson; 07-18-2007 at 07:44 PM.
 
Old 07-18-2007, 08:44 PM   #2
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
Ever suffer from temporary retardedness? my file was miss named 'index.html', it was not named index.php.

problem fixed.

/sigh
 
Old 07-23-2007, 08:06 PM   #3
sady
LQ Newbie
 
Registered: Oct 2003
Posts: 9

Rep: Reputation: 0
php 4 and apache displaying source

I have the same proble but my files are named corectly and even my mail program shows the source.
 
Old 07-26-2007, 06:02 PM   #4
Jason_Bassett
LQ Newbie
 
Registered: Oct 2005
Location: Thurrock, Essex, England
Distribution: Gentoo/Ubuntu
Posts: 12

Rep: Reputation: 0
Sady

Have you installed php4?

On Debian based distibution:

apt-get install php4

I have same issue at the moment with apache/php4 on my Asterisk server.

Last edited by Jason_Bassett; 08-19-2010 at 08:02 AM.
 
Old 07-27-2007, 06:24 AM   #5
TylerD75
Member
 
Registered: Aug 2004
Location: Norway
Distribution: Gentoo
Posts: 96

Rep: Reputation: 18
Have you started Apache with:
APACHE2_OPTS="-D PHP4" # Or PHP5, depending on your version

I'm not sure in what file you need to put it, but on a Gentoo system it goes in /etc/conf.d/apache2
 
Old 08-07-2007, 02:55 PM   #6
walterbyrd
Member
 
Registered: Apr 2004
Posts: 734

Rep: Reputation: 46
I am having the same problem. I had apache 1.3 and php4 installed, and they worked. But, I wanted to run qcodo, which requires php5. So I removed apache, and php4, and installed apache2 and php5.

# php -v
PHP 5.2.3-1+b1 (cli) (built: Jun 21 2007 20:58:46)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

# ps -ef | grep apache2
root 15067 1 0 14:46 ? 00:00:00 apache2 -k start
www-data 15069 15067 0 14:46 ? 00:00:00 apache2 -k start
www-data 15070 15067 0 14:46 ? 00:00:00 apache2 -k start
www-data 15071 15067 0 14:46 ? 00:00:00 apache2 -k start
www-data 15072 15067 0 14:46 ? 00:00:00 apache2 -k start
www-data 15073 15067 0 14:46 ? 00:00:00 apache2 -k start
root 15076 3593 0 14:46 pts/1 00:00:00 grep apache2

Also apache2 seems to work with html files.

Oddly, when I enter localhost in my url, I get:

http://localhost/apache2-default/

Where does this apache2-default come from?

Also, there was no httpd.conf set up. Is there supposed to be one? Apache2 was complaining about it, so I did a touch httpd.conf in the /etc/apache2 directory, and apache started working. But apache won't work with php5.
 
Old 08-08-2007, 11:10 AM   #7
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
walter what distro are you running?

as far as httpd.conf goes (on Fedora at least) httpd.conf resides in the conf directory under your apache root (/etc/apache2 in your case), the core of your configuration will actually reside in a seperate directory: conf.d under your apache root, anything with a '.conf' in that directory is read by apache.

I would make sure that you have the php5 modules set to load in the conf.d/php.conf file.
 
  


Reply



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.0.52, t1lib-5.0.2, php-apache2-5.0.2 wizard7423 Slackware 2 04-04-2011 08:09 PM
Apache2 is serving PHP source files unless called without the extension rjlee Linux - General 3 12-08-2006 06:17 AM
Apache2 displays html source only with 2.6 kernel centosian Debian 2 01-14-2006 10:43 AM
Have installed PHP for Apache2 but source code showing Tomo3000 SUSE / openSUSE 4 08-04-2005 07:14 PM
php5 apache2 mysql4 don't work, php does not seem to read php.ini atom Linux - Software 5 03-24-2005 11:05 AM

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

All times are GMT -5. The time now is 01:10 PM.

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