astroboy has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

Is anything special required to compile PHP::Interpreter - say PHP compiled with specific settings? I just configure then compiled PHP v5.1.6 with the following options:

./configure --enable-embed --with-mysql --with-apxs=/usr/local/apache/ +bin/apxs
Yet I can't get PHP::Interpreter to compile. During "make test" I get
make test PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" " +test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/1....................NOK 1 # Failed test 'use PHP::Interpreter;' # in t/1.t at line 6. # Tried to use 'PHP::Interpreter'. # Error: Can't load '/usr/local/downloads/PHP-Interpreter-1.0.1/b +lib/arch/auto/PHP/Interpreter/Interpreter.so' for module PHP::Interpr +eter: /usr/local/lib/libphp5.so: undefined symbol: ap_rwrite at /usr/ +local/lib/perl5/5.8.7/i686-linux/DynaLoader.pm line 230. # at (eval 3) line 2 # Compilation failed in require at (eval 3) line 2. # BEGIN failed--compilation aborted at t/1.t line 6.

similar errors follow

I'm not a C programmer and don't know even where to start looking at this. Any advice appreciated

Replies are listed 'Best First'.
Re: Problems installing PHP::Interpreter
by almut (Canon) on Apr 28, 2007 at 07:51 UTC

    It appears your problem is related to having built PHP as an apache module (i.e. --with-apxs).

    You might find this thread interesting, in which the module's author states

    "I didn't mean to say that the embed SAPI and mod_php SAPI where fully mutually exclusive (though I wouldn't be shocked if that was the case). What is definitely mutually exclusive is building them at the same time in the same tree. The build process simply doesn't support that."

    How are you planning to use PHP::Interpreter? Do you actually need PHP as an apache module? As it looks, quite a bit of fiddling would be required in that case...   If you're really determined, you might start without --with-apxs, and then, after all other problems have been resolved, come back to your original plan ;)   Good luck anyway!

      Well I have a Perl CMS that generates static files, which is in this instance are PHP (similar in intent to Bricolage, but on a much smaller scale). However, there is a new requirement, where some of the content needs to be dynamic, and the solution has been for the Perl backend to generate the files to disk and then use LWP to fetch the content via the webserver and then display it. This is pretty yucky and inefficient, so I figured PHP::Interpreter could be the solution.

      Since Apache is already installed with various other modules, I figured that it's too late to add PHP as a static build without building all other modules and Apache from scratch too, hence attempting to build it as an Apache module. However, I now see that the alternative to PHP::Interpreter, PHP, doesn't work with PHP built as an Apache module, so I guess the same reasoning applies in this instance...

        astroboy, did you ever figure this problem out? i'm having the same problems running/compiling PHP interpreter (i'm trying to install Bricolage also)

        -Tony
        abiacco@formatdynamics.com
Re: Problems installing PHP::Interpreter
by f00li5h (Chaplain) on Apr 28, 2007 at 06:49 UTC

    This is just a wild flailing stab in the dark PHP::Interpreter may require that you install php5 first...

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;
      Yep, that's what the first part of my post describes
Re: Problems installing PHP::Interpreter
by Khen1950fx (Canon) on Apr 29, 2007 at 00:26 UTC
    By default, PHP builds shared libraries; however, it seems that when you use  --enable-embed, you have to specify type, either static or shared. The documentation wasn't clear about whether static or shared was default in this situation. I would rebuild PHP with --enable-embed=shared and see what happens. Good luck!
      I have solved the problem by installing a seperate php-instance. This is usefull in the case, when you need a normal php-installation.

      Get the source for php version 5.1.6, because the actual version generates some troubles.

      Configure the sources with the following command:
      sudo ./configure --prefix=/usr/local/embedphp --with-config-file-path= +/usr/local/embedphp/etc --with-config-file-scan-dir=/usr/local/embedp +hp/etc/php.d --enable-embed --enable-maintainer-zts --enable-dbase
      Compile the sources an install it. The right embedded libphp5.so library is found in /usr/local/embedphp/lib.

      Get the PHP::Interpreter sources and apply a patch to the Makefile.PL:

      patch:
      87a88 > my $static_library_path = '-Wl,-rpath,'.catdir $prefix, "lib"; 88a90 > push @lddlflags, $static_library_path;
      This links the libphp5.so with a static path.

      The following commands create the Makefile and install the Module correctly:
      sudo patch --verbose --backup Makefile.PL < patch sudo PHP_CONFIG="/usr/local/embedphp/bin/php-config" perl Makefile.PL sudo PHP_CONFIG="/usr/local/embedphp/bin/php-config" make sudo make test sudo make install
      I hope this will fix all problems.

      MfG