Mar 26

PHP and perl are two very popular Web programming languages. They both have many libraries and extensions that can simplify the process of development, but often you can find a perl library you want, and not the corresponding library in PHP. (Perl is older then PHP, so naturally it has a larger selection of libraries and extensions.) This was the main reason that the perl extension for PHP was written.

Installation

download the php perl  extention

# cd /root

# wget http://pecl.php.net/get/perl-1.0.0.tgz

# tar -xvf perl-1.0.0.tgz

# cd perl-1.0.0

you can read the README for detail installation on /root/perl-1.0.0

======================================================================================

Requirements

============

PHP 5.0.0RC2 or later

Perl 5.8.0 or later
Quick install

=============
Step 1. Compile this extension. PHP_PREFIX and PERL_PREFIX mast point to

real

PHP and Perl instalation prefixes.
export PHP_PREFIX="/usr"

export PERL_PREFIX="/usr"

$PHP_PREFIX/bin/phpize

./configure --with-perl=$PERL_PREFIX

--with-php-config=$PHP_PREFIX/bin/php-config

make
Step 2. Install the extension (this step can require root privileges)
make install
Step 3. Add perl extension into your php.ini (this step can require root

privileges)
extension=perl.so

======================================================================================
I assume you have installed the php and perl, youc an use yast / zypper to do that

# php -v
PHP 5.3.1 (cli)

#rpm -qa | grep perl
perl-5.10.0-72.5.i586

you can search php  prefix path by using whereis

# whereis php
php: /usr//local/bin/php /usr/share/man/man1/php.1.gz

# export PHP_PREFIX=”/usr/local”
# export PERL_PREFIX=”/usr”
# $PHP_PREFIX/bin/phpize
# ./configure –with-perl=$PERL_PREFIX
–with-php-config=$PHP_PREFIX/bin/php-config
# make

you will find this error :

/root/perl-1.0.0/php_perl.c:172: warning: initialization from
incompatible pointer type
/root/perl-1.0.0/php_perl.c:173: warning: initialization from
incompatible pointer type
/root/perl-1.0.0/php_perl.c:199: warning: initialization from
incompatible pointer type
/root/perl-1.0.0/php_perl.c:200: warning: initialization from
incompatible pointer type
/root/perl-1.0.0/php_perl.c: In function âphp_perl_zval_to_sv_refâ:
/root/perl-1.0.0/php_perl.c:343: error: ‘zval’ has no member named ‘is_ref’

/root/perl-1.0.0/php_perl.c:1779: warning: assignment from incompatible
pointer type
make: *** [php_perl.lo] Error 1

Solution :

– it turns out the php_perl wasn’t compatible with the php 5.3

–  you need to go to http://svn.php.net/viewvc/pecl/perl/trunk/ -> click php_perl.c -> then click download (http://svn.php.net/viewvc/pecl/perl/trunk/php_perl.c?revision=289243&view=co)

– just wget http://svn.php.net/viewvc/pecl/perl/trunk/php_perl.c?revision=289243&view=co

– you will get php_perl.c\?revision\=289243 just rename it to php_perl.c then paste it to /root/perl-1.0.0/ then

#cd /root/perl-1.0.0
#/usr/local/bin/phpize
#./configure –with-perl=/usr/bin/perl –with-php-config=/usr/local/bin/php-config
#make
#make install

– Edit php.ini
#vim /usr/local/lib/php.ini
– add this line

extension=perl.so

– Restart the apache
#/usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start

– Check your phpinfo
http:/localhost/phpinfo.php

perl

Leave a Reply