LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-15-2005, 01:55 AM   #1
paco36
Member
 
Registered: Jan 2004
Distribution: Fedora Core 2, Gentoo
Posts: 33

Rep: Reputation: 15
Apache not parsing PHP4


Hello,
I am running Gentoo with Apache2 and PHP4. I have been toying around with this for about two days now trying to get this to work correctly, but nothing seems to work. My apache server is up and running. I can go to standard HTML pages and they load fine. I have a php test page which just consists of:

Code:
<html>
<body>
<?php
phpinfo();
?>
</body>
</html>
When I load that up it doesn't parse the PHP... just displays the PHP code when I view the source. I have been through several posts on LinuxQuestions and a few Wikis and can't get anywhere. I emerged php and php_mod and it is in the apache module directory. I have also added LoadModule php4_module extramodules/libphp4.so to my apache2.conf but it still doesn't seem to be working. I have restarted several times as well.

What I don't understand is that it is obviously not parsing the PHP so I would assume that Apache doesn't realize that PHP is installed however when I cause a 404 or any other sort of server error apache brings back the error with:

Apache/2.0.54 (Gentoo/Linux) PHP/4.3.11 mod_ssl/2.0.54 OpenSSL/0.9.7e Server at cynthia Port 80

as the footer of the page. I don't understand that it states PHP/4.3.11 but fails to parse the PHP within the pages.

Any help is much appreciated!

Thanks in advance,
-paco
 
Old 07-15-2005, 02:41 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Do you have:
Code:
AddType application/x-httpd-php .php
in your apache config file? If not try to add it and see what happens. Also try the php page you post, like this:
Code:
<?phpinfo();?>
 
Old 07-15-2005, 10:31 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Apache must be told ...
  • To load the module that provides PHP support.
  • To use this module when dealing with a ".php" file.
  • (Possibly) that it's okay to use PHP on a particular website.
  • Where the PHP-files for a particular web-site can be found.
The Apache log-files will be very helpful. When Apache gets the request for the PHP-file, you can see what was the response...
 
Old 07-15-2005, 11:34 AM   #4
paco36
Member
 
Registered: Jan 2004
Distribution: Fedora Core 2, Gentoo
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks for the quick replies.

I did add
Code:
AddType application/x-httpd-php .php
into my apache config file. I have been just trying to use the
Code:
<?phpinfo();?>
embedded in an html file but it would not work. However I renamed the file to phptest.php and it works perfectly.

What would be preventing the php from being parsed embedded in html vs working fine in a php file?

Thanks in advance,
-paco
 
Old 07-16-2005, 07:21 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
What would be preventing the php from being parsed embedded in html vs working fine in a php file?
That's what
Code:
AddType application/x-httpd-php .php
does. But you can have html code inside a .php file.
 
Old 07-16-2005, 07:49 AM   #6
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Mint
Posts: 181

Rep: Reputation: 32
Have you compiled apache with --with-apxs2?
Can you locate the file: libphp4.so?
 
Old 07-16-2005, 11:07 AM   #7
comprookie2000
Gentoo Developer
 
Registered: Feb 2004
Location: Fort Lauderdale FL.
Distribution: Gentoo
Posts: 3,291
Blog Entries: 5

Rep: Reputation: 58
Do you have this in /etc/conf.d/apache2
Code:
APACHE2_OPTS="-D PHP4"
 
Old 07-17-2005, 10:15 AM   #8
paco36
Member
 
Registered: Jan 2004
Distribution: Fedora Core 2, Gentoo
Posts: 33

Original Poster
Rep: Reputation: 15
Still no luck getting the php tags to get parsed in html. I do have
Code:
APACHE2_OPTS="-D PHP4"
in my /etc/conf.d/apache2. I did not compile apache using --with-apxs2. I just emerged apache. But I can locate libphp4.so.

Really not sure what the deal with this is.

Thanks again,
-paco
 
Old 07-17-2005, 10:23 AM   #9
comprookie2000
Gentoo Developer
 
Registered: Feb 2004
Location: Fort Lauderdale FL.
Distribution: Gentoo
Posts: 3,291
Blog Entries: 5

Rep: Reputation: 58
Try revdep-rebuild -p
see if it can find anything
I had the same problem one time and I think I did something with;
/etc/apache2/conf/modules.d/70_mod_php.conf
Code:
# vim: ft=apache sw=4 ts=4
<IfDefine PHP4>

	# Load the module first
	<IfModule !sapi_apache2.c>
		LoadModule php4_module    extramodules/libphp4.so
	</IfModule>

	# Set it to handle the files
	<IfModule mod_mime.c>
		AddType application/x-httpd-php .php
		AddType application/x-httpd-php .phtml
		AddType application/x-httpd-php .php3
		AddType application/x-httpd-php .php4
		AddType application/x-httpd-php-source .phps
	</IfModule>

	# Fix some bugs
	<Files *.php>
		# keep this the same size as post_max_size in php.ini
		# LimitRequestBody 8388608
	</Files>
	<Files *.php3>
		# keep this the same size as post_max_size in php.ini
		# LimitRequestBody 8388608
	</Files>
	<Files *.php4>
		# keep this the same size as post_max_size in php.ini
		# LimitRequestBody 8388608
	</Files>
	<Files *.phps>
		# keep this the same size as post_max_size in php.ini
		# LimitRequestBody 8388608
	</Files>
	<Files *.phtml>
		# keep this the same size as post_max_size in php.ini
		# LimitRequestBody 8388608
	</Files>

</IfDefine>
 
Old 07-17-2005, 10:36 AM   #10
workman161
LQ Newbie
 
Registered: Mar 2005
Location: Northeast Ohio
Distribution: Fedora Core 4
Posts: 12

Rep: Reputation: 0
Just to be sure, try restarting apache with
# apachectl restart
 
Old 07-17-2005, 11:11 AM   #11
paco36
Member
 
Registered: Jan 2004
Distribution: Fedora Core 2, Gentoo
Posts: 33

Original Poster
Rep: Reputation: 15
I could not get apachectl or revdep working... command not found. However, I did add
Code:
AddType application/x-httpd-php .html
to my /etc/apache2/conf/modules.d/70_mod_php.conf and now it will parse the php in the html pages. I do feel like this will add a lot of overhead to the server running .html pages that do not have any php code in them. But for now it will interpret the php tags embedded in HTML. So it is a bit of a quick fix, but at least it works.

Thanks a lot for all of your help,
-paco
 
Old 07-17-2005, 11:17 AM   #12
workman161
LQ Newbie
 
Registered: Mar 2005
Location: Northeast Ohio
Distribution: Fedora Core 4
Posts: 12

Rep: Reputation: 0
Well, you are supposed to save your php scripts with the .php extension, not the .html. It runs index.php, but not index.html. And the hash (#) means that you are logged in as root, so you needed to run apachectl as root. Its only in one of the sbin directories.
 
Old 07-17-2005, 11:40 AM   #13
comprookie2000
Gentoo Developer
 
Registered: Feb 2004
Location: Fort Lauderdale FL.
Distribution: Gentoo
Posts: 3,291
Blog Entries: 5

Rep: Reputation: 58
To restart apache2 with gentoo its;
/etc/init.d/apache2 restart
to start at boot
rc-update add apache2 default
to see what is starting in default runlevel
rc-update show

Last edited by comprookie2000; 07-17-2005 at 11:42 AM.
 
  


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
PHP4, Apache, and OpenLDAP? Doomhammer13 Linux - Software 2 09-04-2004 07:19 PM
Apache parsing recommendations Reefcrazed Linux - Networking 3 08-17-2004 04:20 PM
PHP4 + apache very slow MurrayL Linux - Software 1 04-23-2004 09:06 AM
Apache and php4 question Gilion Linux - Software 1 10-09-2003 06:24 AM
Configuring Apache 1.37 for PHP4 dogn00dles Linux - Networking 7 07-20-2003 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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