对编译安装的PHP进行升级

准备依赖包和函数库:

yum -yinstall gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetypefreetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-develcurl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-developenssl openssl-devel openldap openldap-devel nss_ldap openldap-clientsopenldap-servers patch perl-CPAN pcre-devel pcre libxslt libxslt-devel php-mcrypt  libmcrypt libmcrypt-devel

 

下载:

http://php.net/downloads.php

 

解压:

tar -zxvf  php-5.6.3.tar.gz  

 

检查配置环境(通用于7.0):

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir=/usr/local --with-jpeg-dir --with-kerberos --with-ldap --with-ldap-sasl --with-libdir=lib64 --with-libxml-dir=/usr/lib64 --with-mcrypt --with-mhash --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pcre-regex=/usr --with-pdo-mysql=mysqlnd --with-pdo-sqlite=shared --with-pear=/usr/local/lib/php --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --disable-rpath --enable-opcache  --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --disable-rpath --enable-opcache --disable-debug --enable-shared --enable-ftp --enable-session --enable-fastcgi --disable-fileinfo --with-fpm-user=username --with-fpm-group=username

 

配置详解:

--with-mysql-sock=/var/run/mysql/mysql.sock  //mysql的sock文件

--with-iconv-dir=/usr/local    //iconv库文件,编译安装icon库时需要指定路径

--with-fpm-user=username--with-fpm-group=username     //指定php-fpm的用户和组

 

configure: error:mcrypt.h not found.

报错内容:configure: error: mcrypt.h notfound. Please reinstall libmcrypt

yum install  php-mcrypt  libmcrypt  libmcrypt-devel

 

编译安装:

ln-s /usr/local/lib/libiconv.so.2 /usr/lib64/

make ZEND_EXTRA_LIBS='-liconv'

报错:

collect2: ld returned 1 exit status  

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

解释:

在安裝 PHP 到系统中时要是发生「undefined reference to libiconv_open'」之类的错误信息,那表示在「./configure 」沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link iconv 函式库参数。

解决方法:

编辑Makefile 大约100 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然后重新再次 make 即可。

然后重新make 顺利通过了

 

 

编译安装php 的时候,执行make报错误

错误:make: *** [ext/mysqli/mysqli.lo] Error 1

[root@localhostphp-5.4.9]# mkdir /usr/local/webserver/mysql/include/mysql

 [root@localhostphp-5.4.9]# ln -s /usr/local/webserver/mysql/include/*/usr/local/webserver/mysql/include/mysql
 [root@localhost php-5.4.9]# make ZEND_EXTRA_LIBS='-liconv'

抛错:

Generating phar.phar
/usr/local/src/php-5.4.9/sapi/cli/php:error while loading shared libraries: libiconv.so.2: cannot open shared objectfile: No such file or directory
make: *** [ext/phar/phar.php] Error 127

解决的方法如下:

#vi /etc/ld.so.conf

在里面加上一行
/usr/local/lib

/usr/lib64

/usr/lib

2.然后运行/sbin/ldconfig

#/sbin/ldconfig

编译make

#makeZEND_EXTRA_LIBS='-liconv'

 

抛错:

Generating phar.phar
chmod: cannot access `ext/phar/phar.phar': No such file or directory
make: [ext/phar/phar.phar] Error 1 (ignored)
Build complete.
Don't forget to run 'make test'.
此处可以忽略不过解决办法如下

#cd  ext/phar/
#cp ./phar.php  ./phar.phar

然后到php5.4文件夹

#makeZEND_EXTRA_LIBS='-liconv'

#make test

#make install

 

 

make clean

make ZEND_EXTRA_LIBS='-liconv'  

make install

 

准备配置文件:

cp php.ini-production/usr/local/webserver/php-d/php-5.5.0/etc/php.ini

 

剩下的根据个人配置 配置,php.ini中的模块设置和php-fpm中的进程池配置按照原先的配置配置。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值