无法在 Ubuntu Server 12.10 中安装 perl 的 pecl 扩展

无法在 Ubuntu Server 12.10 中安装 perl 的 pecl 扩展

我需要从我的 php 文件调用一个 perl 脚本。

我尝试安装 Perl 的 PECL 扩展。

我没有成功。

我尝试了以下操作:

pecl channel-update pear.php.net
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded


pecl install perl
downloading perl-1.0.0.tgz ...
Starting to download perl-1.0.0.tgz (24,358 bytes)
.....done: 24,358 bytes
Validation Error: No release notes found
Parsing of package.xml from file "/tmp/pear/temp/peartf4IJH/package.xml" failed
Download of "pecl/perl" succeeded, but it is not a valid package archive
Error: cannot download "pear/perl"
Download failed
install failed

我正在运行 Ubuntu 服务器 12.10。我的 PHP 版本是

PHP 5.4.6-1ubuntu1.1 (cli) (built: Nov 15 2012 01:18:34) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

我的 Perl 版本是

This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
(with 64 registered patches, see perl -V for more detail)

Copyright 1987-2011, Larry Wall

更新:

我尝试了 2013 年 1 月 23 日最新的 Pecl 安装

它被标记为 1.0.1

运行后我得到了以下内容pecl install perl

downloading perl-1.0.1.tgz ...
Starting to download perl-1.0.1.tgz (25,282 bytes)
.........done: 25,282 bytes
5 source files, building
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_SG:en",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_SG.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_SG:en",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_SG.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
building in /tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1
running: /tmp/pear/temp/perl/configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib
checking for PHP extension directory... /usr/lib/php5/20100525
checking for PHP installed headers prefix... /usr/include/php5
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for perl support... yes, shared
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) nawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/bash /tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/libtool --mode=compile cc  -I. -I/tmp/pear/temp/perl -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/include -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/main -I/tmp/pear/temp/perl -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.14/CORE  -c /tmp/pear/temp/perl/php_perl.c -o php_perl.lo
libtool: compile:  cc -I. -I/tmp/pear/temp/perl -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/include -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/main -I/tmp/pear/temp/perl -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.14/CORE -c /tmp/pear/temp/perl/php_perl.c  -fPIC -DPIC -o .libs/php_perl.o
/tmp/pear/temp/perl/php_perl.c:186:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:186:3: warning: (near initialization for 'php_perl_object_handlers.read_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:187:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:187:3: warning: (near initialization for 'php_perl_object_handlers.write_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:193:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:193:3: warning: (near initialization for 'php_perl_object_handlers.has_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:194:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:194:3: warning: (near initialization for 'php_perl_object_handlers.unset_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:198:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:198:3: warning: (near initialization for 'php_perl_object_handlers.get_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:199:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:199:3: warning: (near initialization for 'php_perl_object_handlers.call_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:202:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:202:3: warning: (near initialization for 'php_perl_object_handlers.get_class_name') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:213:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:213:3: warning: (near initialization for 'php_perl_proxy_handlers.read_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:214:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:214:3: warning: (near initialization for 'php_perl_proxy_handlers.write_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:220:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:220:3: warning: (near initialization for 'php_perl_proxy_handlers.has_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:221:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:221:3: warning: (near initialization for 'php_perl_proxy_handlers.unset_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:225:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:225:3: warning: (near initialization for 'php_perl_proxy_handlers.get_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:226:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:226:3: warning: (near initialization for 'php_perl_proxy_handlers.call_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:229:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:229:3: warning: (near initialization for 'php_perl_proxy_handlers.get_class_name') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:247:1: warning: excess elements in struct initializer [enabled by default]
/tmp/pear/temp/perl/php_perl.c:247:1: warning: (near initialization for 'php_perl_constructor_function') [enabled by default]
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_sv_to_zval_noref':
/tmp/pear/temp/perl/php_perl.c:540:7: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
/tmp/pear/temp/perl/php_perl.c:587:18: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat]
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_call_method':
/tmp/pear/temp/perl/php_perl.c:680:11: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_call':
/tmp/pear/temp/perl/php_perl.c:743:11: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_get_method':
/tmp/pear/temp/perl/php_perl.c:1418:5: error: too few arguments to function 'zend_get_std_object_handlers()->get_method'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_get_properties':
/tmp/pear/temp/perl/php_perl.c:1496:29: error: 'znode_op' has no member named 'op_type'
/tmp/pear/temp/perl/php_perl.c:1497:29: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1498:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1498:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1499:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1499:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1500:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1500:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1501:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1501:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1502:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1502:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_clone':
/tmp/pear/temp/perl/php_perl.c:1666:7: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat]
/tmp/pear/temp/perl/php_perl.c: In function 'zm_info_perl':
/tmp/pear/temp/perl/php_perl.c:1843:3: warning: unknown conversion type character 'v' in format [-Wformat]
/tmp/pear/temp/perl/php_perl.c: In function 'zim_Perl_eval':
/tmp/pear/temp/perl/php_perl.c:1905:13: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
make: *** [php_perl.lo] Error 1
ERROR: `make' failed
www-data@ubuntu-server:/var/virtual/storyzer.com/testperl$ exit
logout

答案1

此答案自 2013 年 1 月 29 日起有效。

首先,在 ubuntu 中执行

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

下载 tgz 文件http://pecl.php.net/package/perl

解压 tar

tar -zxvf perl-1.0.1.tgz

进入解压后的文件夹

cd perl-1.0.1

删除当前的 php_perl.c,因为出于某种原因,它不能与我的 php5 一起使用。

从 github repo 下载另一个 php_perl.chttps://github.com/do-aki/php-ext-perl

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

逐行运行

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  

如果出现类似错误/usr/bin/ld: cannot find -lperl,则需要安装

sudo apt-get install libperl-dev

安装扩展(此步骤可能需要 root 权限)

make install

将 perl 扩展添加到您的 php.ini 中(此步骤可能需要 root 权限)

extension=perl.so

重新启动 php5-fpm

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

运行 Perl 时,可能会遇到与语言环境有关的问题。

查看缺失的语言环境。假设您缺少 en_SG 和 en_SG.UTF-8

尝试

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

然后重新启动。

如果你仍有语言环境问题,

尝试

sudo nano /etc/environment

将缺失的区域设置附加到 LC_ALL

LC_ALL = "en_SG.UTF-8"

重启。

我要感谢tm064#perl 和NullDev#ubuntu 帮助我找到这个解决方案。

相关内容