我想更新我的 AWS EC2 Linux 实例的默认 PCRE 库。当前版本为 8.21 2011-12-12。
我尝试了以下指南:
https://forums.aws.amazon.com/thread.jspa?threadID=234930 https://www.mediawiki.org/wiki/Updating_to_PCRE_8.33_or_Higher
安装成功(make check
返回所有 OK 测试),但似乎 PHP 仍然没有使用正确版本的 PCRE。我想这与指南的步骤有关link
,其中喜欢 32 位库而不是使用 64 位库,但我不太确定如何修复它。安装后重新启动 Apache 和机器。
关于我该如何处理这个问题,有什么建议吗?
先感谢您
附加信息
$ uname -a
Linux ip-10-0-3-82 4.9.75-25.55.amzn1.x86_64 #1 SMP Fri Jan 5 23:50:27 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ sudo yum install pcre
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00
amzn-updates | 2.5 kB 00:00:00
Package pcre-8.21-7.7.amzn1.x86_64 already installed and latest version
Nothing to do
$ pcretest -C
PCRE version 8.41 2017-07-05
Compiled with
8-bit support
UTF-8 support
16-bit support
UTF-16 support
32-bit support
UTF-32 support
Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Parentheses nest limit = 250
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack
$ ldd /usr/bin/php
linux-vdso.so.1 => (0x00007ffe23d73000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007ff4cd67f000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ff4cd465000)
libedit.so.0 => /usr/lib64/libedit.so.0 (0x00007ff4cd236000)
libncurses.so.5 => /lib64/libncurses.so.5 (0x00007ff4cd010000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007ff4ccdef000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007ff4cca6c000)
libz.so.1 => /lib64/libz.so.1 (0x00007ff4cc856000)
libpcre.so.0 => /lib64/libpcre.so.0 (0x00007ff4cc5fe000)
librt.so.1 => /lib64/librt.so.1 (0x00007ff4cc3f6000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff4cc0f4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ff4cbef0000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00007ff4cbcd7000)
libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007ff4cb96f000)
libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007ff4cb722000)
libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007ff4cb43a000)
libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007ff4cb207000)
libcom_err.so.2 => /usr/lib64/libcom_err.so.2 (0x00007ff4cb004000)
libssl.so.10 => /lib64/libssl.so.10 (0x00007ff4cad93000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007ff4ca935000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff4ca71f000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff4ca35b000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007ff4ca159000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff4cd8b6000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff4c9f3d000)
liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007ff4c9d19000)
libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007ff4c9b0b000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007ff4c9908000)
libselinux.so.1 => /usr/lib64/libselinux.so.1 (0x00007ff4c96e7000)
$ ll -ll /lib64 | grep pcre
lrwxrwxrwx 1 root root 16 Nov 20 22:11 libpcre.so.0 -> libpcre.so.0.0.1
-rwxr-xr-x 1 root root 359688 May 27 2015 libpcre.so.0.0.1
$ sudo make install
make install-am
make[1]: Entering directory `/home/ec2-user/pcre-8.41'
make[2]: Entering directory `/home/ec2-user/pcre-8.41'
/bin/mkdir -p '/usr/lib'
/bin/sh ./libtool --mode=install /usr/bin/install -c libpcre.la libpcre16.la libpcre32.la libpcreposix.la libpcrecpp.la '/usr/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.so.1.2.9 /usr/lib/libpcre.so.1.2.9
libtool: install: (cd /usr/lib && { ln -s -f libpcre.so.1.2.9 libpcre.so.1 || { rm -f libpcre.so.1 && ln -s libpcre.so.1.2.9 libpcre.so.1; }; })
libtool: install: (cd /usr/lib && { ln -s -f libpcre.so.1.2.9 libpcre.so || { rm -f libpcre.so && ln -s libpcre.so.1.2.9 libpcre.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcre.lai /usr/lib/libpcre.la
libtool: install: /usr/bin/install -c .libs/libpcre16.so.0.2.9 /usr/lib/libpcre16.so.0.2.9
libtool: install: (cd /usr/lib && { ln -s -f libpcre16.so.0.2.9 libpcre16.so.0 || { rm -f libpcre16.so.0 && ln -s libpcre16.so.0.2.9 libpcre16.so.0; }; })
libtool: install: (cd /usr/lib && { ln -s -f libpcre16.so.0.2.9 libpcre16.so || { rm -f libpcre16.so && ln -s libpcre16.so.0.2.9 libpcre16.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcre16.lai /usr/lib/libpcre16.la
libtool: install: /usr/bin/install -c .libs/libpcre32.so.0.0.9 /usr/lib/libpcre32.so.0.0.9
libtool: install: (cd /usr/lib && { ln -s -f libpcre32.so.0.0.9 libpcre32.so.0 || { rm -f libpcre32.so.0 && ln -s libpcre32.so.0.0.9 libpcre32.so.0; }; })
libtool: install: (cd /usr/lib && { ln -s -f libpcre32.so.0.0.9 libpcre32.so || { rm -f libpcre32.so && ln -s libpcre32.so.0.0.9 libpcre32.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcre32.lai /usr/lib/libpcre32.la
libtool: warning: relinking 'libpcreposix.la'
libtool: install: (cd /home/ec2-user/pcre-8.41; /bin/sh "/home/ec2-user/pcre-8.41/libtool" --silent --tag CC --mode=relink gcc -fvisibility=hidden -g -O2 -version-info 0:5:0 -o libpcreposix.la -rpath /usr/lib libpcreposix_la-pcreposix.lo libpcre.la )
libtool: install: /usr/bin/install -c .libs/libpcreposix.so.0.0.5T /usr/lib/libpcreposix.so.0.0.5
libtool: install: (cd /usr/lib && { ln -s -f libpcreposix.so.0.0.5 libpcreposix.so.0 || { rm -f libpcreposix.so.0 && ln -s libpcreposix.so.0.0.5 libpcreposix.so.0; }; })
libtool: install: (cd /usr/lib && { ln -s -f libpcreposix.so.0.0.5 libpcreposix.so || { rm -f libpcreposix.so && ln -s libpcreposix.so.0.0.5 libpcreposix.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcreposix.lai /usr/lib/libpcreposix.la
libtool: warning: relinking 'libpcrecpp.la'
libtool: install: (cd /home/ec2-user/pcre-8.41; /bin/sh "/home/ec2-user/pcre-8.41/libtool" --silent --tag CXX --mode=relink g++ -fvisibility=hidden -fvisibility-inlines-hidden -O2 -version-info 0:1:0 -o libpcrecpp.la -rpath /usr/lib libpcrecpp_la-pcrecpp.lo libpcrecpp_la-pcre_scanner.lo libpcrecpp_la-pcre_stringpiece.lo libpcre.la )
libtool: install: /usr/bin/install -c .libs/libpcrecpp.so.0.0.1T /usr/lib/libpcrecpp.so.0.0.1
libtool: install: (cd /usr/lib && { ln -s -f libpcrecpp.so.0.0.1 libpcrecpp.so.0 || { rm -f libpcrecpp.so.0 && ln -s libpcrecpp.so.0.0.1 libpcrecpp.so.0; }; })
libtool: install: (cd /usr/lib && { ln -s -f libpcrecpp.so.0.0.1 libpcrecpp.so || { rm -f libpcrecpp.so && ln -s libpcrecpp.so.0.0.1 libpcrecpp.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcrecpp.lai /usr/lib/libpcrecpp.la
libtool: finish: PATH="/sbin:/bin:/usr/sbin:/usr/bin:/sbin" ldconfig -n /usr/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/bin/mkdir -p '/usr/bin'
/bin/sh ./libtool --mode=install /usr/bin/install -c pcretest pcregrep '/usr/bin'
libtool: install: /usr/bin/install -c .libs/pcretest /usr/bin/pcretest
libtool: install: /usr/bin/install -c .libs/pcregrep /usr/bin/pcregrep
/bin/mkdir -p '/usr/bin'
/usr/bin/install -c pcre-config '/usr/bin'
/bin/mkdir -p '/usr/share/doc/pcre-8.41'
/usr/bin/install -c -m 644 doc/pcre.txt doc/pcre-config.txt doc/pcregrep.txt doc/pcretest.txt AUTHORS COPYING ChangeLog LICENCE NEWS README '/usr/share/doc/pcre-8.41'
/bin/mkdir -p '/usr/share/doc/pcre-8.41/html'
/usr/bin/install -c -m 644 doc/html/NON-AUTOTOOLS-BUILD.txt doc/html/README.txt doc/html/index.html doc/html/pcre-config.html doc/html/pcre.html doc/html/pcre16.html doc/html/pcre32.html doc/html/pcre_assign_jit_stack.html doc/html/pcre_compile.html doc/html/pcre_compile2.html doc/html/pcre_config.html doc/html/pcre_copy_named_substring.html doc/html/pcre_copy_substring.html doc/html/pcre_dfa_exec.html doc/html/pcre_exec.html doc/html/pcre_free_study.html doc/html/pcre_free_substring.html doc/html/pcre_free_substring_list.html doc/html/pcre_fullinfo.html doc/html/pcre_get_named_substring.html doc/html/pcre_get_stringnumber.html doc/html/pcre_get_stringtable_entries.html doc/html/pcre_get_substring.html doc/html/pcre_get_substring_list.html doc/html/pcre_jit_exec.html doc/html/pcre_jit_stack_alloc.html doc/html/pcre_jit_stack_free.html doc/html/pcre_maketables.html doc/html/pcre_pattern_to_host_byte_order.html doc/html/pcre_refcount.html doc/html/pcre_study.html doc/html/pcre_utf16_to_host_byte_order.html doc/html/pcre_utf32_to_host_byte_order.html doc/html/pcre_version.html doc/html/pcreapi.html doc/html/pcrebuild.html doc/html/pcrecallout.html doc/html/pcrecompat.html doc/html/pcredemo.html doc/html/pcregrep.html '/usr/share/doc/pcre-8.41/html'
/usr/bin/install -c -m 644 doc/html/pcrejit.html doc/html/pcrelimits.html doc/html/pcrematching.html doc/html/pcrepartial.html doc/html/pcrepattern.html doc/html/pcreperform.html doc/html/pcreposix.html doc/html/pcreprecompile.html doc/html/pcresample.html doc/html/pcrestack.html doc/html/pcresyntax.html doc/html/pcretest.html doc/html/pcreunicode.html '/usr/share/doc/pcre-8.41/html'
/bin/mkdir -p '/usr/share/doc/pcre-8.41/html'
/usr/bin/install -c -m 644 doc/html/pcrecpp.html '/usr/share/doc/pcre-8.41/html'
/bin/mkdir -p '/usr/include'
/usr/bin/install -c -m 644 pcreposix.h pcrecpp.h pcre_scanner.h '/usr/include'
/bin/mkdir -p '/usr/share/man/man1'
/usr/bin/install -c -m 644 doc/pcre-config.1 doc/pcregrep.1 doc/pcretest.1 '/usr/share/man/man1'
/bin/mkdir -p '/usr/share/man/man3'
/usr/bin/install -c -m 644 doc/pcre.3 doc/pcre16.3 doc/pcre32.3 doc/pcre_assign_jit_stack.3 doc/pcre_compile.3 doc/pcre_compile2.3 doc/pcre_config.3 doc/pcre_copy_named_substring.3 doc/pcre_copy_substring.3 doc/pcre_dfa_exec.3 doc/pcre_exec.3 doc/pcre_free_study.3 doc/pcre_free_substring.3 doc/pcre_free_substring_list.3 doc/pcre_fullinfo.3 doc/pcre_get_named_substring.3 doc/pcre_get_stringnumber.3 doc/pcre_get_stringtable_entries.3 doc/pcre_get_substring.3 doc/pcre_get_substring_list.3 doc/pcre_jit_exec.3 doc/pcre_jit_stack_alloc.3 doc/pcre_jit_stack_free.3 doc/pcre_maketables.3 doc/pcre_pattern_to_host_byte_order.3 doc/pcre_refcount.3 doc/pcre_study.3 doc/pcre_utf16_to_host_byte_order.3 doc/pcre_utf32_to_host_byte_order.3 doc/pcre_version.3 doc/pcreapi.3 doc/pcrebuild.3 doc/pcrecallout.3 doc/pcrecompat.3 doc/pcredemo.3 doc/pcrejit.3 doc/pcrelimits.3 doc/pcrematching.3 doc/pcrepartial.3 doc/pcrepattern.3 '/usr/share/man/man3'
/usr/bin/install -c -m 644 doc/pcreperform.3 doc/pcreposix.3 doc/pcreprecompile.3 doc/pcresample.3 doc/pcrestack.3 doc/pcresyntax.3 doc/pcreunicode.3 doc/pcrecpp.3 '/usr/share/man/man3'
/bin/mkdir -p '/usr/include'
/usr/bin/install -c -m 644 pcre.h pcrecpparg.h pcre_stringpiece.h '/usr/include'
/bin/mkdir -p '/usr/lib/pkgconfig'
/usr/bin/install -c -m 644 libpcre.pc libpcreposix.pc libpcre16.pc libpcre32.pc libpcrecpp.pc '/usr/lib/pkgconfig'
make install-data-hook
make[3]: Entering directory `/home/ec2-user/pcre-8.41'
ln -sf pcre_assign_jit_stack.3 /usr/share/man/man3/pcre16_assign_jit_stack.3
ln -sf pcre_compile.3 /usr/share/man/man3/pcre16_compile.3
ln -sf pcre_compile2.3 /usr/share/man/man3/pcre16_compile2.3
ln -sf pcre_config.3 /usr/share/man/man3/pcre16_config.3
ln -sf pcre_copy_named_substring.3 /usr/share/man/man3/pcre16_copy_named_substring.3
ln -sf pcre_copy_substring.3 /usr/share/man/man3/pcre16_copy_substring.3
ln -sf pcre_dfa_exec.3 /usr/share/man/man3/pcre16_dfa_exec.3
ln -sf pcre_exec.3 /usr/share/man/man3/pcre16_exec.3
ln -sf pcre_free_study.3 /usr/share/man/man3/pcre16_free_study.3
ln -sf pcre_free_substring.3 /usr/share/man/man3/pcre16_free_substring.3
ln -sf pcre_free_substring_list.3 /usr/share/man/man3/pcre16_free_substring_list.3
ln -sf pcre_fullinfo.3 /usr/share/man/man3/pcre16_fullinfo.3
ln -sf pcre_get_named_substring.3 /usr/share/man/man3/pcre16_get_named_substring.3
ln -sf pcre_get_stringnumber.3 /usr/share/man/man3/pcre16_get_stringnumber.3
ln -sf pcre_get_stringtable_entries.3 /usr/share/man/man3/pcre16_get_stringtable_entries.3
ln -sf pcre_get_substring.3 /usr/share/man/man3/pcre16_get_substring.3
ln -sf pcre_get_substring_list.3 /usr/share/man/man3/pcre16_get_substring_list.3
ln -sf pcre_jit_exec.3 /usr/share/man/man3/pcre16_jit_exec.3
ln -sf pcre_jit_stack_alloc.3 /usr/share/man/man3/pcre16_jit_stack_alloc.3
ln -sf pcre_jit_stack_free.3 /usr/share/man/man3/pcre16_jit_stack_free.3
ln -sf pcre_maketables.3 /usr/share/man/man3/pcre16_maketables.3
ln -sf pcre_pattern_to_host_byte_order.3 /usr/share/man/man3/pcre16_pattern_to_host_byte_order.3
ln -sf pcre_refcount.3 /usr/share/man/man3/pcre16_refcount.3
ln -sf pcre_study.3 /usr/share/man/man3/pcre16_study.3
ln -sf pcre_utf16_to_host_byte_order.3 /usr/share/man/man3/pcre16_utf16_to_host_byte_order.3
ln -sf pcre_version.3 /usr/share/man/man3/pcre16_version.3
ln -sf pcre_assign_jit_stack.3 /usr/share/man/man3/pcre32_assign_jit_stack.3
ln -sf pcre_compile.3 /usr/share/man/man3/pcre32_compile.3
ln -sf pcre_compile2.3 /usr/share/man/man3/pcre32_compile2.3
ln -sf pcre_config.3 /usr/share/man/man3/pcre32_config.3
ln -sf pcre_copy_named_substring.3 /usr/share/man/man3/pcre32_copy_named_substring.3
ln -sf pcre_copy_substring.3 /usr/share/man/man3/pcre32_copy_substring.3
ln -sf pcre_dfa_exec.3 /usr/share/man/man3/pcre32_dfa_exec.3
ln -sf pcre_exec.3 /usr/share/man/man3/pcre32_exec.3
ln -sf pcre_free_study.3 /usr/share/man/man3/pcre32_free_study.3
ln -sf pcre_free_substring.3 /usr/share/man/man3/pcre32_free_substring.3
ln -sf pcre_free_substring_list.3 /usr/share/man/man3/pcre32_free_substring_list.3
ln -sf pcre_fullinfo.3 /usr/share/man/man3/pcre32_fullinfo.3
ln -sf pcre_get_named_substring.3 /usr/share/man/man3/pcre32_get_named_substring.3
ln -sf pcre_get_stringnumber.3 /usr/share/man/man3/pcre32_get_stringnumber.3
ln -sf pcre_get_stringtable_entries.3 /usr/share/man/man3/pcre32_get_stringtable_entries.3
ln -sf pcre_get_substring.3 /usr/share/man/man3/pcre32_get_substring.3
ln -sf pcre_get_substring_list.3 /usr/share/man/man3/pcre32_get_substring_list.3
ln -sf pcre_jit_exec.3 /usr/share/man/man3/pcre32_jit_exec.3
ln -sf pcre_jit_stack_alloc.3 /usr/share/man/man3/pcre32_jit_stack_alloc.3
ln -sf pcre_jit_stack_free.3 /usr/share/man/man3/pcre32_jit_stack_free.3
ln -sf pcre_maketables.3 /usr/share/man/man3/pcre32_maketables.3
ln -sf pcre_pattern_to_host_byte_order.3 /usr/share/man/man3/pcre32_pattern_to_host_byte_order.3
ln -sf pcre_refcount.3 /usr/share/man/man3/pcre32_refcount.3
ln -sf pcre_study.3 /usr/share/man/man3/pcre32_study.3
ln -sf pcre_utf32_to_host_byte_order.3 /usr/share/man/man3/pcre32_utf32_to_host_byte_order.3
ln -sf pcre_version.3 /usr/share/man/man3/pcre32_version.3
make[3]: Leaving directory `/home/ec2-user/pcre-8.41'
make[2]: Leaving directory `/home/ec2-user/pcre-8.41'
make[1]: Leaving directory `/home/ec2-user/pcre-8.41'
[ec2-user@ip-10-0-3-82 pcre-8.41]$ sudo mv -v /usr/lib/libpcre.so.* /lib
‘/usr/lib/libpcre.so.1’ -> ‘/lib/libpcre.so.1’
‘/usr/lib/libpcre.so.1.2.9’ -> ‘/lib/libpcre.so.1.2.9’
[ec2-user@ip-10-0-3-82 pcre-8.41]$ sudo ln -sfv ../../lib/$(readlink /usr/lib/libpcre.so) /usr/lib/libpcre.so
‘/usr/lib/libpcre.so’ -> ‘../../lib/libpcre.so.1.2.9’
$ sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
答案1
在许多情况下,更新库的链接方法是有效的(尽管你不熟悉构建包,但你也会冒着产生比解决问题更多问题的风险,但会影响你的包管理器的感受)。
PHP 与它自己的 PCRE 副本捆绑在一起,因此您可能正在运行 PHP 的旧版本(不太可能,因为甚至 php-5.4 也与 PCRE-8.37 捆绑在一起)。在这种情况下,更换系统 PCRE 不会产生任何影响,但输出ldd
会确认您正在使用系统 PCRE。
您正在使用旧系统 PCRE(AMI 源自 RHEL,库仅在主要版本上更新)。那么问题是 PCRE v8.30引入了一些 API 更改,这触发了库版本的更新(按照惯例因为 API 函数pcre_info()
已被删除)。对于 < 8.30,将调用库libpcre.so.0
,对于 ≥ v8.30,将调用libpcre.so.1
。
$ diff -u pcre-8.21/libpcre.la pcre-8.30/libpcre.la
[...]
# The name that we can dlopen(3).
-dlname='libpcre.so.0'
+dlname='libpcre.so.1'
# Names of this library.
-library_names='libpcre.so.0.0.1 libpcre.so.0 libpcre.so'
+library_names='libpcre.so.1.0.0 libpcre.so.1 libpcre.so'
您可以从粘贴的安装日志中确认这一点。
假设您使用的是系统 PHP,它将针对系统版本进行编译和链接libpcre.so.0
,因此您的说法是正确的,链接是问题所在,但它是 PHP 的链接。它永远不会使用libpcre.so.1
您安装的。 (如果你足够努力地搜索,你会发现人们提倡使用一些符号链接技巧来解决这个问题,我不推荐这样做,API 更改且版本更改是有原因的.)
在您链接到作者的示例中,从 8.31 升级到 8.33,因此没有遇到问题。
最简单的选择是检查是否有使用更新 PCRE 的更新 PHP 包可用;或更新您的 AMI 版本。 (一个不太简单的选择是构建您自己的 PHP,通常不推荐,这里包含它只是为了完整性。从configure
输出中的详细信息开始phpinfo()
,并确保忽略选项--with-pcre-regex=/usr
或类似选项,以选择更新的捆绑 PCRE。准备安装地段开发包的数量...)