Linux中编译安装php,Ubuntu中编译安装PHP

关于怎么在Ubuntu中获取php源码和解压就不再说了。

编译的参数为:

./configure --prefix=/opt/php --with-bz2 --with-mcrypt --with-mhash --with-openssl --with-pdo-mysql --with-pdo-pgsql --with-mysqli --with-pgsql --enable-calendar --with-gettext --with-iconv --enable-mbstring --with-pspell  --enable-exif --with-gd --with-png-dir=/opt/php --with-jpeg-dir=/opt/php --with-imap --enable-bcmath --with-gmp --enable-pcntl --enable-sysvshm --enable-shmop --with-tidy --with-curl --enable-ftp  --with-ldap --enable-sockets --enable-fpm --enable-soap --with-xmlrpc  --enable-wddx --with-xsl  --with-kerberos --with-imap-ssl

--prefix参数的值指定了php的安装路径,如果不指定的话那么安装后php的文件将分散在各个地方,不利于管理,指定路径后所有的php文件将全部存放在指定的路径下。其他参数全部能够在php手册上面能够找到,只要查看函数参考章节下面的每个扩展的安装说明就可以找到需要的参数了。这些参数可以根据自己的需要增加或者减少。如果以后需要添加一个扩展,只需要在原有的参数上加上新的扩展参数然后重新编译安装就可以了(只要--prefix参数的位置不变就可以覆盖以前的安装的php)。

编译完成后执行make命令,make执行完成后执行sudo make install命令进行安装。

在安装过程中可能会遇到各种问题,例如依赖包缺失等等,安装过程中遇到的问题有如下这些:

configure: error:utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information

解决办法:apt-get install libc-client2007e-dev

configure: error: Cannot find ldap libraries in /usr/lib.

解决办法:ln -fs /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法:sudo apt-get install libmcrypt-dev

CONFIGURE: ERROR: CANNOT FIND LIBPQ-FE.H. PLEASE SPECIFY CORRECT POSTGRESQL INSTALLATION PATH

解决办法:sudo apt-get install postgresql-server-dev-9.5

configure: error: Cannot find pspell

解决办法:sudo apt-get install libpspell-dev

configure: error: Cannot find libtidy

解决办法:sudo apt-get install libtidy-dev

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

解决办法:sudo apt-get install libxslt1-dev

/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup@@OPENLDAP_2.4_2'

//usr/lib/x86_64-linux-gnu/liblber-2.4.so.2: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

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

解决办法:在PHP源码目录下 vim Makefile 找到 EXTRA_LIBS 行(带有很多参数的行),在行末添加 ‘ -llber ‘ 保存退出再次make即可。

以上只是一部分遇到的问题,由于我在安装的时候遇到的一部分问题没有记录,所以目前只有这几个问题,下次安装时再补充。

PHP 的详细介绍:请点这里

PHP 的下载地址:请点这里

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值