手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu中编译安装PHP

[日期:2016-03-12] 来源:Linux社区  作者:zouyitangzaishuo [字体:大 中 小]

关于怎么在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中的ini配置 http://www.linuxidc.com/Linux/2016-02/128442.htm

剖析PHP脚本的超时机制 http://www.linuxidc.com/Linux/2016-02/128441.htm

Ubuntu 14.04下搭建PHP开发环境PDF  http://www.linuxidc.com/Linux/2016-02/128330.htm

PHP 7革新与性能优化 http://www.linuxidc.com/Linux/2015-09/123136.htm

PHP 7 ,你值得拥有  http://www.linuxidc.com/Linux/2015-06/118847.htm 

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0  http://www.linuxidc.com/Linux/2015-05/117960.htm 

CentOS 6.3 安装LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm 

在部署LNMP的时候遇到Nginx启动失败的2个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm 

Ubuntu安装Nginx php5-fpm MySQL(LNMP环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm 

《细说PHP》高清扫描PDF+光盘源码+全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm 

CentOS 6中配置PHP的LNMP的开发环境  http://www.linuxidc.com/Linux/2013-12/93869.htm 

PHP 的详细介绍:请点这里
PHP 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/129153tm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款