Click to See Complete Forum and Search --> : [Resolved] Apache-2.0/PHP-4.3.1/RedHat-8.0


daveo
05-20-2003, 05:54 PM
This is an Apache/PHP configuration question (as best as I can tell).

I recently decided to "rough it" and removed my RPMs of Apache, PHP and mod_perl from my system to compile them from scratch. I decided to do this because I couldn't get PHP (PHPNuke or Keystone) to work. (I couldn't get Slash to work either, but that isn't a PHP issue).

I now have Apache 2.0.45 working, mod_perl with Apache::ASP working and PHP-4.3.1 installed (but not working). I understand that in Apache 2.0 PHP is now a filter and, therefore, might not behave the same way as it did in Apache-1.3.x. Soooooo...


I put two LoadModule statements in to confirm that the first was being seen. It complained and skipped the second.
I put in the requisite AddType lines
I tried several variations with <Files xxx> and <Directory xxx> sections to no avail.
I added the Alias to point to the appropriate "real" directory
Output on browser produces "blank" page with PHP source in "View->Source".


I will mention that I tried running some of the scripts from the command line (as in "php admin.php > admin.html") and then loaded the html output in my browser. That comes up fine so PHP appears to be installed properly (at least part of it). I just can't get it to work as a module(filter?).

The Files section has only the following:
<Files ~ (\.php)>
SetInputFilter PHP
SetOutputFilter PHP
</Files>

Any ideas?
--daveo

tsinka
05-21-2003, 03:16 AM
Hi,

did you also add

AddModule mod_php4.c ?

PHP won't work as a module without doing that.

daveo
05-21-2003, 08:34 AM
AddModule is a 1.3.x command. It is rejected in Apache 2.0.

I read in the documentation (somewhere) that Apache 2.0 treats PHP as a filter, not a module.

As far as I can find, the configuration required is:

------------------------- Start of PHP config ------------------
LoadModule modules/libphp4.so
AddType application/x-httpd-php .php

Alias /phpnuke/ /var/www/phpnuke/html/

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
DirectoryIndex index.php
------------------------ End of PHP config -------------------

The main httpd.conf file has a line "Include conf.d/*.conf". The above config lines are in "conf.d/php.conf".

PHP was built with

./configure \
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-xml \
--enable-versioning \
--with-config-file-path=/etc/php4

php.ini is a copy of "php.ini-dist" with possibly very minor changes. I haven't figured out the settings in there yet...

For what it is worth, Apache-2.0.45 was built including (this is a very abbreviated list)
--enable-mods-shared=ALL
--enable-ext-filter
--with-mpm=prefork
--enable-so
--disable-asis

(I don't remember why "disable-asis" is in there...)

Can't think of any other important things right now...

--daveo

daveo
05-21-2003, 08:59 AM
Whoops, I forgot on the Apache build... I let mod_perl take care of that. It had:

perl Makefile.PL \
APACHE_SRC=/home/build/httpd-2.0.45 \
DO_HTTPD=1 \
USE_APACI=1 \
PERL_MARK_WHERE=1 \
EVERYTHING=1 \
MP_APXS=/usr/local/apache2/bin/apxs \
APACHE_PREFIX=/usr/local/apache2

(the bit in the last post was from a config script that I was going to use but used the mod_perl stuff instead)

--daveo

daveo
05-21-2003, 05:26 PM
In the hopes that somebody will actually have an idea on this, I offer the following additional info:

The behavior is the same if I leave in or comment out the "LoadModule" and "AddType" lines from the config file.

In both cases, I get PHP source code in the resulting page in my browser.

--daveo

daveo
05-22-2003, 10:37 AM
Last night's rebuild...


Apache-2.0.45 was built with:

./configure \
--enable-mods-shared=ALL \
--with-ssl=/usr/local/ssl \
--with-mpm=prefork

Followed by:

PHP-4.3.1 was built with:

./configure \
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-xml \
--enable-versioning \
--with-config-file-path=/etc/php4

php configuration elements:

LoadModule php4_module modules/libphp4.so
Alias /phpnuke/ /var/www/phpnuke/html/
ScriptAlias /cgi-nuke/ /var/www/phpnuke/html/

AddType application/x-httpd-php .php
Action application/x-httpd-php /usr/local/bin/php

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>

-------------------------
I was hoping that, if I couldn't get it to work as a filter, I could get it to work as a cgi-bin animal... to no avail.

I still get only the PHP source code in the browser window.

A lot of people have looked at this thread, doesn't anyone have an idea? This could easily be a simple configuration setting that I am missing since I am new to setting up PHP. Any ideas would be welcome. Maybe an ENV VAR needs to be passed into Apache and I am missing that... I don't know.

--daveo :confused:

tsinka
05-22-2003, 02:55 PM
Hi,

next try :)

did you ensure that engine=on is set in your php.ini. I was able to reproduce your problem but I'm not sure if you have the same problem.

Where did you put the AddType And Filter directives ? There are two cases where they will not be parsed by apache while reading the config file.

1) You put them inside a directory section that points to a non existen directory
2) you put them inside a IfModule section of a module that has not been loaded.

In that cases my browser showed an empty page like you described.

daveo
05-22-2003, 03:55 PM
The AddType directive is at "zero level" (not inside any tags).

php.ini says "engine = On"

Is there some sort of "minimal" php.ini file that I can try just to see if there is something else strange there?

I noticed that in posts about the 1.3.x versions of Apache that PHP would make some sort of "I am here" statement in the error_log during startup. Is it supposed to do that in 2.0? I am getting no such messages. The only confirmation that I get that anything is going on is the "second LoadModule statement skipped for libphp4.so" thingy.

I also ran "strings" on libphp4.so to see if it was looking for "php.ini" somewhere else but the only place I could find "/etc/php4" was in the stored configuration options. I found a reference to "/usr/local/etc" so I put a soft link there to the php.ini file... Still nothing...

AAAaaaacccckkkk!!!!

I even put a softlink under my document_root directory to the "html" directory in the PHP stuff for PHPNuke. Same behavior.

--daveo :confused:

tsinka
05-22-2003, 05:18 PM
Hi,

apache doesn't display any php4 info in the error log in my case (ok, I checked it on a windows server with apache and php4 but it shouldn't differ that much on RedHat in this case).

If you enable the info module and the <Location /server-info>
directive then the output of http://myhost/server-info differs depending on the php4 module being enabled or not.

When the php module is enabled there will be an additional output like:

Module Name: sapi_apache2.c
Content handlers: none
Configuration Phase Participation: Create Directory Config, Merge Directory Configs
Request Phase Participation: Post-Read Request
Module Directives:
php_value - PHP Value Modifier
php_flag - PHP Flag Modifier
php_admin_value - PHP Value Modifier (Admin)
php_admin_flag - PHP Flag Modifier (Admin)
PHPINIDir - Directory containing the php.ini file
Current Configuration:


If that output doesn't show up in your case then the module hasn't been loaded successfully.

At the bottom of the output you can see the current configuration. There should be the Filter tags. The php code should be parsed even if you remove the AddType application/x-httpd-php .php directive and just set the input and output filters.

Some people posted on other forums that they had problems if they used both AddType and the filters at the same time.

daveo
05-23-2003, 05:37 PM
Well, we are getting a little further, albeit with the same end results...

I get exactly the same output as in your last post. Exactly, as in the line "Current Configuration" shows up and there is nothing after it.

We may be onto something when you talk about "Filter tags". What sets the filter tags? I do not appear to have any set.

--daveo

tsinka
05-24-2003, 01:26 AM
Hi,

I wasn't clear in my post, with filter tags I meant SetInputFilter PHP and SetOutputFilter PHP which you already have. Current configuration can be empty.

I think it would be helpful if you send your httpd.conf and the output of the server-info.

Maybe there's something I couldn't think of wrong in the configuration.

Please also post the external includes of your httpd.conf. It must be something very simple, I tested the stuff on Linux and Windows and it worked with just including the module and setting the PHP output and input filters. I didn't need to add the AddType application/x-httpd-php .php line.

daveo
05-25-2003, 04:12 PM
I am inclined to agree with you that is should be something simple. I saw something somewhere that suggested that there might be a problem with running PHP and mod_perl in the same Apache instance. Does this sound familiar?


I have attached "sanitized" copies of the httpd.conf and php.ini files in one attachment. IPs and internal addresses have been changed. Comments have been deleted to avoid confusion and cut file length.

Reply from /server-info:
--------------------------------------------------------------------------------

Module Name: sapi_apache2.c
Content handlers: none
Configuration Phase Participation: Create Directory Config, Merge Directory Configs
Request Phase Participation: Post-Read Request
Module Directives:
php_value - PHP Value Modifier
php_flag - PHP Flag Modifier
php_admin_value - PHP Value Modifier (Admin)
php_admin_flag - PHP Flag Modifier (Admin)
PHPINIDir - Directory containing the php.ini file
Current Configuration:

--------------------------------------------------------------------------------
I am assuming that you didn't want the entire output from "server-info". Let me know if you need more...

I hope that this helps. If not, I may be forced to compile yet another version of Apache 1.3.x on a different port to get at this stuff!

--daveo

tsinka
05-25-2003, 04:18 PM
I couldn't find the attachement :(

daveo
05-25-2003, 04:27 PM
Well, I will try again...

I just noticed the "Valid file extensions" thingy. It is now called "httpd.txt" so it might let me upload it...

--daveo

tsinka
05-25-2003, 05:00 PM
Hi,

where are the two include statements for the files php.conf and perl.conf ? Are they located at the position where you inserted them in you posted text file ? Try to move the includes somewhere after the "standard" LoadModule directives or to the end of httpd.conf.

tsinka
05-25-2003, 05:32 PM
Hi,

two more ideas:

1) I read some posts about mod_perl preventing apache to load the php module.

Try the following:

First load just the two modules mod_perl and mod_php4. Then put all the perl and php configuration stuff below the two LoadModule lines.

2) configure apache to use php as cgi.

daveo
05-25-2003, 06:26 PM
Ok. 3 ideas:

1st/2nd: It appears that ideas 1 and 2 are similar, basically, LoadModule everything first that do the extra config stuff at the bottom (near the VirtualHost stuff). Correct me if this is wrong.

3rd: do all else normally except setting up PHP as cgi. Is there something other than setting the ScriptAlias, AddType and Action directives?

I think I tried as cgi before and got the same results. I say "think I tried" because I don't know if things were in the right order or not. :o

I will try these suggestions shortly. Any guidance that you want to give on the 'cgi' part would be nice since you are currently on-line. I will, most likely, be trying these after the kids are in bed. :)

Thanks again for all so far...

--daveo

tsinka
05-26-2003, 01:54 AM
Hi,

I think it would be better to get the stuff working with the so version of php :)

What happened with php when you tried to deactivate the mod_perl stuff ? Did it work ?

I found a url yesterday where someone described how he compiled apache2, php-4.3.0, mod_perl,mod_ssl and other stuff, I'll look where it was and send you the url. If it worked for him, why shouldn't it work for you ? I think he was running RedHat 8.0 :)

tsinka
05-26-2003, 02:03 AM
Hi,

the person wasn't using RedHat 8.0 but it should work anyways:
It's a nice step by stell tutorial and includes ssl stuff (and shows how to create a self signed certificate)

http://lamps.efactory.de/e-lamps-2-0.shtml

By the way, I read another post of someone who wrote that for him using the mpm switch when compiling apache broke up the php execution. Try to recompile apache without

--with-mpm=prefork

I must say that I don't have RedHat 8.0 installed yet but I think I'll go and get it :)

daveo
05-26-2003, 07:09 PM
I'm slowly working through that guy's document and, consequently, adding PDF and a signed certificate to the mix :cool:.

As it turns out, the default for Linux is

"--with-mpm=prefork"

so if you leave that line out, it defaults to it. Just for kicks, I tried

"--without-mpm"

and (as I suspected from reading the docs) you can't do that. mpm is what talks to the network ports. Ya learn something new every day (if you are lucky). :)

Anyway, I am still working at it. More later.

--daveo

daveo
05-27-2003, 12:35 AM
In the words of the infamous Valley Girls (and guys?) of California: "Oh my Gawd!".

First: I have it working (loud fanfare) and can break (and fix) it easily.

Second: order of directives has "a little" to do with it; but, only the order of PHP directives, however, are at issue. The rest can go in the "conf.d/*.conf" files as suggested by the Apache2 sample httpd.conf.

The one "extra element" that you are probably not using is "Apache::ASP" (http://www.apache-asp.org/). That "stuff" isn't the real source of the problem, but the "Files" directive that I was using turned out to be a killer!

See if you can explain this behavior:

With the "Files" section as follows:

<Files ~ (\.asp)?>
... some settings ...
</Files>

With that setup, PHP will not work but the Perl ASP scripts do. When I change it to:

<Files ~ (\.asp)$>
... some settings ...
</Files>

BOTH Apache::ASP and PHP stuff work. Now, mind you, the PHP setup was:

<Files ~ (\.php)?>
... some settings ...
</Files>

and that caused no problems.

By the way, I have no idea why the "?" was in the ".asp" Files directive, but it was...

Any ideas?

I will wait to see if anyone has any ideas on this before closing out this thread. The answer(s) could be interesting/useful.

--daveo

tsinka
05-27-2003, 08:05 AM
Hi,

I think the ? after the brackets means 0,1 so all files that ended with .asp and all file that didn't end with .asp matched so all files matched. By using $ you match all files that exactly end with .asp. I would suggest to use (\.php)$ instead of (\.php)? because it would render all files sections after the php section useless.

daveo
05-27-2003, 08:40 AM
Ummmm... yeah. That was pretty silly on my part. Especially since I am the one who has to explain regexps to all my co-workers.

For some reason, there was a

<Brain>
Mode=slow
</Brain>

section in the file near that part. I had been thinking (or, more accurately, NOT thinking) that it would match the "?" in the URL for parameters.

Thank-you for your patience in helping on this one.

daveo
05-27-2003, 11:53 AM
Closing Summary:

1) Order can be important
2) Watch those FilesMatch and Files directives.

1) The order of my directives was important, possibly because I had another <Files> directive that was too general, I will have to investigate that.

2) my PHP scripts were not being seen because the

<Files ~ (\.asp)?>

directive was grabbing them and passing them to Apache::ASP (which passed them along as simple text). The correct syntax should have been:

<Files ~ "\.asp$">

which would have found files ending in ".asp".

--daveo