Docunext


PHP Interpreter

June 25th, 2008

This looks very interesting... should be helpful in getting me more acquainted with perl. To install on Lenny, I first installed php5-dev, but unfortunately that still didn't do it. Looks like this module needs the --embed option set in the php interpreter to be used. Going to have to hold of on this to install it on a testing environment rather than a development machine.

Now I'm trying to get PHP installed in such a way I can use it... I tried getting the perl makefile to use the php headers installed by debian, but it wants to look in /usr/local/*. Hmmm.

UPDATE: I was able to get this going. :-)

  • php-5.2.6* ./configure --enable-embed=shared --enable-maintainer-zts
  • make
  • make install

That put the new php into /usr/local. Then I installed PHP::Interpreter manually after trying to get it via CPAN, which didn't happen. When I tried to use it, I got complaints about Exporter, so I added that as a use include, and it worked! Getting it to work with mod_perl and even as a regular cgi-bin file was challenging, but I got it to go:

CGI

#!/usr/bin/perl
use Exporter;
use PHP::Interpreter;
print "Content-Type: text/html\
n\
n";
my $php = PHP::Interpreter->new();
my $old_hander = $php->set_output_handler(\
$scalar);
my $output = $php->eval(q^ phpinfo(); ^);
my $outbuf = $php->get_output;
print $outbuf;

mod_perl

sub handler {
  my $r = shift;
  my $php = PHP::Interpreter->new();
  my $scalar;
  my $old_hander = $php->set_output_handler(\
$scalar);
  my $output = $php->eval(q^ phpinfo(); ^);
  my $outbuf = $php->get_output;
  $r->print($outbuf);
  return Apache2::Const::OK;
}

Why bother doing this? The novelty of it is pretty good by itself!

Next up, a more challenging configuration setup:

    --enable-embed=shared \
    --enable-maintainer-zts \
    --disable-rpath \
    --disable-static \
    --with-pic \
    --with-pear=/usr/share/php \
    --enable-calendar \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-sysvmsg \
    --enable-bcmath \
    --with-bz2 \
    --enable-ctype \
    --without-gdbm \
    --with-iconv \
    --enable-ftp \
    --with-gettext \
    --enable-mbstring \
    --enable-shmop \
    --enable-sockets \
    --enable-wddx \
    --with-libxml-dir=/usr \
    --with-xsl=/usr \
    --with-zlib \
    --with-openssl=/usr \
    --enable-zip

The Server API Ham and Cheese ?

External Links

¥

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020