Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

<?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?

share|improve this question

migrated from stackoverflow.com Jan 24 '13 at 2:27

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

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.

share|improve this answer
    
raw.github.com/do-aki/php-ext-perl/… is now broken. It does not match with the latest header file. – rht Apr 28 '13 at 15:22

There is a newer version of perl-1.0.1.tgz available from 2013-01-23. It has more adequate package.xml (Tried under SuSE 12.2 - everything is OK).

share|improve this answer
    
I am using ubuntu 12.10. I cannot get it to work. I got make: *** [php_perl.lo] Error 1 ERROR: `make' failed – Kim Stacks Jan 29 '13 at 1:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .