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

    Hi,

    did you also add

    AddModule mod_php4.c ?

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

      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

        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

          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

            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 😕

              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.

                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 😕

                  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.

                    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

                      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.

                        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

                          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

                            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.

                              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.

                                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

                                  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 🙂

                                    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 🙂

                                      I'm slowly working through that guy's document and, consequently, adding PDF and a signed certificate to the mix 🆒.

                                      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