Monday 22 January 2018

php - am using ubuntu 12.10. unable to use PHP_PERL extension. Unable to install the extension as well


I need to run a Perl script because I need a module that Perl has that PHP does not.


This is my code for testing purposes in PHP




echo ("Hello World");


$perl = new Perl();
$perl->require("someperlscript.pl");

I got


Hello WorldPHP Fatal error:  Class 'Perl' not found in /var/virtual/abc.com/testperl/testperl.php on line 7
PHP Stack trace:
PHP 1. {main}() /var/virtual/abc.com/testperl/testperl.php:0

Then I tried to install to no avail.


What should I do to get Perl running inside a ubuntu 12.10 server edition?



Answer



This answer works as of 29 Jan 2013.


First of all, inside ubuntu do


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

to download the tgz file from http://pecl.php.net/package/perl


Unzip the tar


tar -zxvf perl-1.0.1.tgz

Go into the uncompressed folder


cd perl-1.0.1

Remove the current php_perl.c because for some reason, it did not work with my php5.


Download another php_perl.c from github repo https://github.com/do-aki/php-ext-perl


wget https://raw.github.com/do-aki/php-ext-perl/a3d7db22eb7964ea9cb39ea2f866d10df26655d4/php_perl.c

Run this line by line


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

If you get errors like /usr/bin/ld: cannot find -lperl, then you need to install


sudo apt-get install libperl-dev

Install the extension (this step can require root privileges)


make install

Add perl extension into your php.ini (this step can require root privileges)


extension=perl.so

Restart your php5-fpm


sudo /etc/init.d/php5-fpm restart

You may get issues to do with locale when you run Perl.


Look at the missing locales. Assuming you have missing en_SG and en_SG.UTF-8


Try


sudo locale-gen en_SG en_SG.UTF-8
sudo dpkg-reconfigure locales

and then reboot.


If you still have locale issues,


Try


sudo nano /etc/environment

Append the missing locale to LC_ALL


LC_ALL = "en_SG.UTF-8"

Reboot.


I want to thank tm064 from #perl and NullDev from #ubuntu for helping me with this solution.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...