LinuxQuestions.org
Visit Jeremy's Blog.
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 08-26-2007, 02:57 PM   #1
flegace
LQ Newbie
 
Registered: Aug 2007
Location: British Columbia, Canada
Distribution: CentOS 5
Posts: 2

Rep: Reputation: 0
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?
 
Old 08-26-2007, 03:32 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Hi and welcome to LQ.

Try renaming the index.html page to index.php.
 
Old 08-26-2007, 05:57 PM   #3
flegace
LQ Newbie
 
Registered: Aug 2007
Location: British Columbia, Canada
Distribution: CentOS 5
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 08-26-2007, 09:42 PM   #4
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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.
 
Old 08-28-2007, 10:34 AM   #5
aquatux
Member
 
Registered: Jul 2005
Distribution: Ubuntu 14.04
Posts: 50

Rep: Reputation: 15
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.
 
Old 08-30-2007, 01:12 AM   #6
rlee923
Member
 
Registered: Jan 2006
Location: Australia
Distribution: Fedora Core 6
Posts: 88

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

Try this way.
 
  


Reply

Tags
apache, centos5, fedora 7, php



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
HELP! no im client works with yahoo in fedora, centos & ubuntu (firewall is down) marianrobert Linux - Networking 1 07-21-2007 12:24 PM
Fedora Core 5 & PHP Heinz09 Linux - General 2 09-11-2006 05:52 AM
[9.1 pro] Apache, MySQL & PHP ... not working! Dannyarr SUSE / openSUSE 5 10-17-2004 02:42 PM
PHP & Apache on Slackware 8.1 not working chrisx Slackware 3 02-02-2004 02:49 AM
PHP & MySQL, working, and yet getting a blank results page linxtc Programming 5 08-24-2003 04:51 PM

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

All times are GMT -5. The time now is 08:44 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