Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP & Apache on RH9

Status
Not open for further replies.

artfulbodger

Technical User
Jan 3, 2005
109
US
Hello everyone...

Hopefully someone can assist me here. I am trying to install PHP & Apache on a RH9 server. The good news is that everything (including the MySQL installation) goes without a hitch or any errors. However, I cannot get any PHP code in my pages to run. To see what I am doing, please visit this page:
As you can see, it is pretty simple code with some HTML statements and PHP statements. Obviously, the HTML is working just fine. PHP won't work to save my life.

Here are the software versions:

PHP 4.3.11 (cli) (built: May 16 2005 20:54:55)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

# ./httpd -v
Server version: Apache/1.3.33 (Unix)
Server built: May 16 2005 20:02:25

I have modified my httpd.conf file as instructed with the approproate LoadModule and AddModule statements as well as added the AddType statements.

This is about the 10th time recompiling this thing and I am slowly gong bald. Help!
 
You're using client-side script tags, not server-side PHP tags (where the script actually would run). Try it with real PHP tags instead:

<?
echo "Sample PHP Code";
?>

Lee
 
Thanks for the quick response.

I copied your code exactly and unfortunately, nothing happened.

Is there anything I can do to test PHP without going through apache? I just want to see if I can narrow the problem.

 
I have an update (good news actually)...

I decided to create a test PHP page to see if it would parse the code. Thankfully, it worked.
The only problem that I have now is that I cannot get PHP to parse coded embedded in an HTML document.

I have a feeling it is something in my httpd.conf file, but I have stared at this so much that I fear I am overlooking the obvious.

I posted it to my site to save some space here....
Thanks in advance for all the help - I am not exactly new to Linux, but not a vetran either.
 
Actually, your test program is NOT working correctly. If you do a Show Source after bringing it up, no HTML is shown, only your text. That tells me that your web server is serving PHP code as TEXT.

Create a test PHP script consisting of
Code:
<?
phpinfo();
?>
And try bringing it up. It should look something like the output displayed by
For help with you Apache configuration, you might get more help in the Apache Forum.

Ken
 
Thanks for your responses....

The server was working - the code that I put there was basically:

<? php

print "PHP Sample code";

?>

In retrospect, phpinfo() would have been better.

The good news is that I found what the "problem" was - it was intentionally done that way. After speeding along my dependency of Rogain, I found that it was working properly to beginn with. The html file won't be parsed for php code by default

Turns out, the last place I was, the sysadminn set it up so that all html pages would be parsed for php code. This is done by modifying the httpd.conf line:

AddType application/x-http .html .htm .php

This is considered a "bad practice" and should be avoided. Besides encouraging bad html page development (I am going to have to modify my pages now), it impacts server performace as every page must be parsed by the PHP engine.

The proper way is to use the "include" statement to reference external php source files on your HTML pages.


So...to conclude this adventure...everything ended up working properly.

Thanks to everyone who assisted. You guys helped tremendously!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top