本文发布于Cylon的收藏册,转载请著名原文链接~


编译错误

错误:同时指定了fpm与aspxs2方式错误

You've configured multiple SAPIs to be build.You can build only one SAPI module 
and CLI binary at the same time

原因:导致的原因是我的配置参数中同时使用了–enable-fpm 与–with-apxs2,因此编译的时候出错了,去掉其中的任意一个参数编译成功。

image-20221214223427069

系统缺少libtool

make ***[libphp5.la] Error 1

解决方法:在编译PHP版本时,产生错误 make ***[libphp5.la] Error 1

错误原因:系统缺少libtool

解决办法:yum install libtool-ltdl-devel

make过程错误

make: *** [sapi/cli/php] Error 1

原因:在 「./configure 」 沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link 的 iconv 库参数。

报错提示:

libiconv.so.2: cannot open shared object file: No such file or directory mak

/root/tools/php-7.1.3/ext/iconv/iconv.c:2591: undefined reference to `libiconv_open'
ext/xmlrpc/libxmlrpc/.libs/encodings.o: In function `convert':
/root/tools/php-7.1.3/ext/xmlrpc/libxmlrpc/encodings.c:74: undefined reference to `libiconv_open'
/root/tools/php-7.1.3/ext/xmlrpc/libxmlrpc/encodings.c:82: undefined reference to `libiconv'
/root/tools/php-7.1.3/ext/xmlrpc/libxmlrpc/encodings.c:102: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

解决方法1:编辑Makefile 我的php7.1.3在88行的地方:在最后加上 -liconv,或者编译时,编译参数指定 iconv 安装目录不会报此错误。

 113 EXTRA_LIBS = -lcrypt -lz -lexslt -lcrypt -lrt -lmcrypt -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -l
     z -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lcurl -lxml2 -lz -lm -lfreetype -lmysqlclient -lm -lr
     t -ldl -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxslt -lxml
     2 -lz -lm -lssl -lcrypto -lcrypt 「-liconv」

解决方法2:自己打包替换系统内的iconv包

make: *** [ext/phar/phar.php] Error 127

/root/dev/php-5.3.6/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127

解决:网上找到的解决办法是

ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib/

照做后仍然报错,原因是该方法适用于32位系统,64位系统应使用下面的这行

ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/

另外:在编译的时候,不写mysql的路径,而使用mysqlnd代替,也可解决该问题的出现。

参考:

echo "/app/mysql/lib/libmysqlclient.so.18" >>/etc/ld.so.conf
ldconfig

configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no

原因:目前不明

  checking for sysvipc shared memory support... no
  checking for mmap() using MAP_ANON shared memory support... no
  checking for mmap() using /dev/zero shared memory support... no
  checking for mmap() using shm_open() shared memory support... no
  checking for mmap() using regular file shared memory support... no
  checking "whether flock struct is linux ordered"... "no"
  checking "whether flock struct is BSD ordered"... "no"
  configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

解决方法:执行如下后,重新编译即可

export LD_LIBRARY_PATH=/app/mysql/lib

参考资料:http://www.jianshu.com/p/0d6d188c2ddc

php5.5 mysql5.6

Don't know how to define struct flock on this system, set --enable-opcache=no

解决方法:

ln -s /app/mysql/lib/libmysqlclient.so /usr/lib
ln -s /app/mysql/lib/libmysqlclient.so.18.1.0 /usr/lib
vim /etc/ld.so.conf
/usr/lib
ldconfig -v 

在虚拟机中编译PHP问题

错误 make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

原因:这是由于内存小于1G所导致。

解决办法:在./configure加上选项。

--disable-fileinfo Disable  # <==fileinfo support 禁用 fileinfo

configure: error: Cannot find libmysqlclient under /app/mysql.

经查,问题是64位系统中 libmysqlclient 默认安装到了 /usr/lib64/mysql/ 目录下,而 /usr/lib 目录下没有相应文件,但是php编译时,要去 /usr/lib目录下查找

解决:ln -s /app/mysql/lib /app/mysql/lib64

make install错误

/home/tools/php-5.3.27/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make[1]: *** [install-pear-installer] 错误 127
make: *** [install-pear] 错误 2

原因:mysql5.5的的lib路径跟之前的不一样 解决:

echo "/app/mysql/lib" >> /etc/ld.so.conf
ldconfig

make install正确安装

PHP5.3

/home/tools/php-5.3.27/build/shtool install -c ext/phar/phar.phar /app/php-5.3.27/bin
ln -s -f /app/php-5.3.27/bin/phar.phar /app/php-5.3.27/bin/phar
Installing PDO headers:          /app/php-5.3.27/include/php/ext/pdo/

PHP5.5

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

本文发布于Cylon的收藏册,转载请著名原文链接~

链接:https://www.oomkill.com/2016/10/install-troubleshooting/

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」 许可协议进行许可。