http://www.linux-centos.com/2014/11/16/%E7%BC%96%E8%AF%91%E5%8D%87%E7%BA%A7%E4%BB%8Ephp5-2-17%E5%88%B0php5-4-35/
编译升级从PHP5.2.17到PHP5.4.35
1. 备份/usr/local/php
1
|
tar zcvf /bak/php5.2.17.tar.gz /usr/local/php
|
2. 备份/etc/php.ini
1
|
cp /etc/php.ini /etc/php.5.2.17.ini.bak
|
3. 备份
1
|
cp /usr/local/apache/modules/libphp5.so libphp5.so.bak
|
4. 开始编译升级PHP5.4.35
先删除/usr/local/php
1
|
rm -rf /usr/local/php
|
安装依赖库
1
|
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel gd* bzip2 bzip2-devel ncurses ncurses-devel net-snmp-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libmcrypt libmcrypt-devel
|
建立一个软链接
1
2
3
4
5
|
## 64位
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64
## 32位
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib
|
下载、编译、安装PHP5.4.35
1
2
3
4
5
6
7
8
9
10
11
|
cd /usr/local/src
wget http://cn2.php.net/get/php-5.4.35.tar.gz/from/this/mirror
tar zxvf php-5.4.35.tar.gz
cd php-5.4.35
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-freetype-dir --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-session --with-gettext
make && make install
|
配置php.ini
1
2
3
4
5
6
7
8
|
cp php.ini-production /usr/local/php/etc/php.ini #复制php配置文件到安装目录
rm -rf /etc/php.ini #删除系统自带的配置文件
ln -s /usr/local/php/etc/php.ini /etc/php.ini #创建配置文件软链接
## 修改/etc/php.ini
date.timezone = PRC
expose_php = Off
display_errors = Off
|
重启APACHE测试是否安装成功
1
|
service httpd restart
|
安装APC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
cd /usr/local/src
wget http://pecl.php.net/get/APC-3.1.9.tgz
tar zxvf APC-3.1.9.tgz
cd APC-3.1.9
/usr/local/php/bin/phpize
./configure --enable-apc --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"
extension = apc.so
; APC
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = on
## 验证APC是否正常安装
php -m | grep apc
|
安装完成以后请参考编译安装PHP5.2.17+MySQL5.5.34+Apache2.2.25对php.ini进行配置
可能出现的问题
1. “/usr/local/src/php-5.4.35/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory”
1
2
3
4
5
|
## 64位
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64
## 32位
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib
|
2. make install的时候出现”cp: cannot stat `ext/phar/phar.phar': No such file or directory”
进入/usr/local/src/php/ext目录
1
|
cp phar.php phar.phar
|
3. configure: error: Cannot find ldap libraries in /usr/lib.
1
|
cp -frp /usr/lib64/libldap* /usr/lib/
|