LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Fedora 7 & CentOS 5 PHP not working (https://www.linuxquestions.org/questions/linux-server-73/fedora-7-and-centos-5-php-not-working-579982/)

flegace 08-26-2007 02:57 PM

Fedora 7 & CentOS 5 PHP not working
 
I have searched through Google, Apache & PHP websites and the distro support forums for an answer. So far I have either missed the obvious or I have not asked the right question.

I have installed CentOS 5 (twice) and Fedora 7 (once to confirm problem). Using the Anaconda installer, I configured Apache to run PHP. For certainty, I have checked off all the modules for both mysql and php.

The http.conf file looks fine. It loads an included php.conf located in the /etc/http/conf.d directory. That file includes the line "LoadModule php5_module modules/libphp5.so". The AddType and AddHandler lines are also loaded.

I have opened up the firewall for port 80. I have disabled SELinux.

I have written a quick test file (index.html) that requests phpinfo() as follows:
<html>
<head>
<title></title>
<meta content="">
<style></style>
</head>
<body>
PHP Test begins
<?php phpinfo(); ?>
PHP Test ends
</body>

</html>

The browser only returns the "PHP Test begins" and "PHP Test ends" text strings. Checking the page source reveals that Apache has passed the source directly to the browser without interpretting the phpinfo request.

I am stumped, any theories on what the problem could be?

reddazz 08-26-2007 03:32 PM

Hi and welcome to LQ.

Try renaming the index.html page to index.php.

flegace 08-26-2007 05:57 PM

I renamed the index.html to index.php and stripped out the html stuff. To my surprise, it worked. That is different behaviour than what I expected. I understood that Apache would send the php code to the interpreter and it would return completed code back to Apache. At least, that has been the case for anything I have done previously.

I am puzzled now. I will have to do some research on upgrading my php skills. Thank you kindly for your help with this.

reddazz 08-26-2007 09:42 PM

The reason why your php code in the index.html didn't work properly is because your php config file was probably set to only regard files with a *.php extension as having php code. This is the default behaviour on most apache+php installations I have seen. I have noticed that the phpinfo() function, works with or without the html tags.

aquatux 08-28-2007 10:34 AM

Code:

AddType application/x-httpd-php .html .htm
I added this line to my httpd.conf to solve this problem. It will allow PHP embedded in .html or .htm file to be processed. You will be able to use .php .html or .htm and they all will process the php.

rlee923 08-30-2007 01:12 AM

AAAAhhh. Make sure you are loading the php page through server side control (eg http://localhost/index.php).

Try this way.


All times are GMT -5. The time now is 12:03 AM.