LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   apache2 displays PHP source instead of evaluating (https://www.linuxquestions.org/questions/linux-server-73/apache2-displays-php-source-instead-of-evaluating-570533/)

Hewson 07-18-2007 07:22 PM

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

Hewson 07-18-2007 08:44 PM

Ever suffer from temporary retardedness? my file was miss named 'index.html', it was not named index.php.

problem fixed.

/sigh

sady 07-23-2007 08:06 PM

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.

Jason_Bassett 07-26-2007 06:02 PM

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.

TylerD75 07-27-2007 06:24 AM

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

walterbyrd 08-07-2007 02:55 PM

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.

Hewson 08-08-2007 11:10 AM

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.


All times are GMT -5. The time now is 07:05 PM.