centos php5.2.17,[编译安装]centos升级php5.2.17到php5.3.15

一. php原来状态:

1.1 原来的版本:

/usr/local/php5/bin/php -v

PHP 5.2.17 (cli) (built: Oct 17 2011 19:38:14)

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend

Technologies

1.2 原安装目录: /usr/local/php5

1.3 原安装的编译参数:

./configure --prefix=/usr/local/php5 --with-png-dir=/usr

--enable-sysvmsg --with-gd --with-freetype-dir=/usr

--enable-mbstring --enable-gd-native-ttf

--without-gdbm  --with-gettext

--with-ncurses  --with-gmp

--with-iconv

--with-jpeg-dir=/usr

--with-png-dir=/usr

--enable-sockets

--with-libxml-dir=/usr  --with-zlib  --with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config

--with-libdir=lib64

--enable-fastcgi

--enable-force-cgi-redirect

--with-openssl=/usr

--with-curl=/usr

--enable-bcmath  --enable-fpm

--with-mcrypt=/usr/local

--enable-soap  --enable-pcntl

--enable-ftp=shared

1.4 原配置文件:/usr/local/php5/lib/php.ini

注意备份

1.5 原来的扩展:

[线上]: apc, redis, memcache

[线下]: xdebug, redis, memcache

二. 备份原重要文件

2.0

安装快速备份命令bcp

bcp命令:https://github.com/RickieL/bcp/blob/master/bcp

用于快速备份文件或目录。

wget https://nodeload.github.com/RickieL/bcp/tarball/master -O

bcp.tar.gz

tar xzf  bcp.tar.gz

cd RickieL-bcp-f65e017

chmod +x bcp

mv bcp /bin/bcp

2.1 备份php.ini配置文件

bcp /usr/local/php5/lib/php.ini

2.2 备份php-fpm.conf配置文件

bcp /usr/local/php5/etc/php-fpm.conf

2.3 备份/etc/init.d/php-fpm 启动文件

bcp

/etc/init.d/php-fpm

2.4 备份原来的整个程序目录:

bcp /usr/local/php5

三.

php5.3.15的相关操作

3.1 新版本:

# /usr/local/php5/bin/php -v

PHP 5.3.15 (cli) (built: Aug  2 2012

17:28:29)

Copyright (c) 1997-2012 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend

Technologies

3.2 新安装目录: /usr/local/php5

3.3 新的编译参数:

./configure  --prefix=/usr/local/php5

--with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config

--with-mysql-sock=/data/logs/mysql/mysql.sock

--with-gd  --with-zlib

--enable-bcmath --enable-shmop

--with-curl  --with-curlwrappers

--enable-fpm --enable-mbstring --enable-ftp

--enable-gd-native-ttf --with-openssl --enable-pcntl

--enable-sockets --with-xmlrpc --enable-zip --enable-soap

--without-pear --with-gettext  --with-mcrypt

--with-libdir=lib64  --with-freetype-dir=/usr

--with-png-dir=/usr --enable-sysvmsg

--enable-sysvshm  --enable-sysvsem

--with-gmp --with-jpeg-dir=/usr

--with-libxml-dir=/usr

--disable-phar --enable-exif

3.4 编译参数解释:

--prefix  php的安装目录

--with-config-file-path  Set the

path in which to look for php.ini [PREFIX/lib]

设置php.ini文件的查找目录[默认

PREFIX/lib 目录]

--with-mysql[=DIR]  Include MySQL support.  DIR is the MySQL base

directory.  If mysqlnd is passed as DIR,

the MySQL native driver will

be used [/usr/local]

包括mysql的支持。

DIR指mysql的基础目录.

--with-mysqli[=FILE]  Include MySQLi support.  FILE is

the path to mysql_config.  If mysqlnd is passed as

FILE,

the MySQL

native driver will be used [mysql_config]

包含mysqli支持. FILE为mysql_config文件的目录.

--with-mysql-sock[=DIR]  MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket

pointer.

If unspecified, the default locations are

searched

指定mysql的unix

socket文件的位置。

--with-gd[=DIR]  Include GD support.

DIR is the GD library base install directory

[BUNDLED]

包含GD的支持. DIR为GD库的安装目录。

--with-zlib[=DIR]  Include ZLIB support (requires zlib

>= 1.0.9)

包含ZLIB支持(要求 zlib >= 1.0.9)

--enable-bcmath  Enable bc style precision

math functions

开启具有bc精度的数学函数

--enable-shmop  Enable

shmop support

开启shmop支持(Shmop is an easy to use set of functions that

allows

PHP to

read, write, create and delete Unix shared memory segments.)

--with-curl[=DIR]  Include cURL support

包含cURL支持

--with-curlwrappers  EXPERIMENTAL: Use cURL for url streams

实验:用cURL打开url流

--enable-mbstring  Enable multibyte string support

开启多字节字符串支持

--enable-fpm  EXPERIMENTAL: Enable building

of the fpm SAPI executable

--with-fpm-user[=USER]  Set the user for

php-fpm to run as. (default: nobody)

--with-fpm-group[=GRP]  Set the group for

php-fpm to run as. For a system user, this

should

usually be set to match the fpm username (default: nobody)

开启fpm支持,后面两个参数用户设置运行fpm的用户和用户组

--enable-ftp  Enable FTP support

开启FTP支持

--enable-gd-native-ttf  GD: Enable TrueType string function

GD: 开启TrueType字符串函数

--with-openssl[=DIR]  Include OpenSSL support (requires OpenSSL

>= 0.9.6)

包含OpenSSL支持(要求

OpenSSL版本>=0.9.6)

--enable-pcntl  Enable

pcntl support (CLI/CGI only)

开启pcntl支持(仅CLI/CGI模式下)

--enable-sockets  Enable sockets support

开启sockets支持

--with-xmlrpc[=DIR]  Include XMLRPC-EPI support

开启

XMLRPC-EPI支持

--enable-zip  Include Zip read/write support

开启Zip的read/write支持

--enable-soap  Enable

SOAP support

开启SOAP支持

--without-pear  Do not

install PEAR

不安装PEAR

--with-gettext[=DIR]  Include GNU gettext support

保安GNU

gettext 支持

--with-mcrypt[=DIR]  Include mcrypt support

包含

mcrypt 支持

--with-libdir=NAME  Look for libraries in .../NAME rather than

.../lib

搜索库文件的名字(64位一般用 lib64)

--with-freetype-dir[=DIR] GD: Set the path to FreeType 2

install prefix

GD: 设置FreeType 2的安装目录

--with-jpeg-dir[=DIR]  GD: Set the path to libjpeg install prefix

GD: 设置libjpeg的安装目录

--with-png-dir[=DIR]  GD: Set the path to libpng install prefix

GD: 设置的libpng安装目录

--enable-sysvmsg  Enable sysvmsg support

开启sysvmsg支持

--enable-sysvsem  Enable System V semaphore

support

开启System V 的信号支持

--enable-sysvshm  Enable the System V shared

memory support

开启system v 共享内存支持

--with-gmp[=DIR]  Include GNU MP support

开启GNU

MP支持

--with-libxml-dir[=DIR]  LIBXML: libxml2

install prefix

LIBXML:libxml2的安装目录

--disable-phar  Disable

phar support

--enable-exif  Enable

EXIF (metadata from images) support

开启EXIF(图像元信息)支持

3.5 编译后的安装

make  #编译

make install  #安装

bcp /usr/local/php5/lib/php.ini

bcp  /usr/local/php5/etc/php-fpm.conf

cp  php.ini-production  /usr/local/php5/lib/php.ini

#复制后,参照原来5.2的php.ini文件修改新php.ini的配置

cp  /usr/local/php5/etc/php-fpm.conf.default

/usr/local/php5/etc/php-fpm.conf

#请参照原来5.2的php-fpm.conf文件进行配置修改

##注意##5.3.15的php-fpm.conf文件与5.2.17的格式很大区别,原来的给xml格式的,新版的php-fpm.conf格式和php.ini一样,但里面的总体字段名没有更改,而且字段说明更加有用。$$

vi  /usr/local/php5/etc/php-fpm.conf

#编辑

user = www  #设置php-fpm运行账号为www

group = www  #设置php-fpm运行组为www

pid = run/php-fpm.pid  #取消前面的分号

3.6 安装php扩展

memcache扩展

tar xzf memcache-2.2.6.tgz

cd memcache-2.2.6

/usr/local/php5/bin/phpize

./configure --enable-memcache

--with-php-config=/usr/local/php5/bin/php-config

make && make install

3.7 php的启动

bcp /etc/rc.d/init.d/php-fpm

#备份原php-fpm

cp /usr/local/src/php-5.3.15/sapi/fpm/init.d.php-fpm

/etc/rc.d/init.d/php-fpm

#拷贝php-fpm到启动目录

chmod +x /etc/rc.d/init.d/php-fpm

#添加执行权限

chkconfig php-fpm on  #设置开机启动

四. 错误解决

4.1

PEAR package PHP_Archive not installed: generated phar will

require PHP's phar extension be enabled.

该错误是由以下原因造成的:

a. php默认编译phar和pear

b.

因为暂时没有用到pear,所以关闭了pear(--without-pear)

c.

phar属于pear维护的一个包,所以报这个错误。

解决办法:

##因为开发中没有使用phar,所以连phar也一起关闭就可以了。

法1.

编译参数加上(--disable-phar),即:同时使用编译参数

--without-pear  --disable-phar

法2.

两个(pear和phar)都不禁用。即:编译时,不对pear和phar做控制

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值