注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

永福的技术博客

Linux运维

 
 
 

日志

 
 

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

2012-08-03 16:20:17|  分类: 软件编程 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
一. 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模式下)
/**
Process Control support in PHP implements the Unix style of process creation, program execution, signal handling and process termination. Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.
*/
--enable-sockets        Enable sockets support
                        开启sockets支持
--with-xmlrpc[=DIR]     Include XMLRPC-EPI support
                        开启 XMLRPC-EPI支持
/**
xmlrpc-epi-php is a PHP C extension that utilizes xmlrpc-epi to provide a high performance, easy to use, php native interface to xmlrpc. There is no complex type API to use. Instead, manipulate your values as you normally would, then call a single encode routine to translate that data into xml.
*/
--enable-zip            Include Zip read/write support
                        开启Zip的read/write支持
--enable-soap           Enable SOAP support
                        开启SOAP支持
/**
The SOAP extension can be used to write SOAP Servers and Clients. 
*/
--without-pear          Do not install PEAR
                        不安装PEAR
/**
PEAR is a framework and distribution system for reusable PHP components.
*/
--with-gettext[=DIR]    Include GNU gettext support
                        保安GNU gettext 支持
/**
GNU `gettext' is an important step for the GNU Translation Project, as it is an asset on which we may build many other steps. This package offers to programmers, translators, and even users, a well integrated set of tools and documentation. Specifically, the GNU `gettext' utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages. These tools include a set of conventions about how programs should be written to support message catalogs, a directory and file naming organization for the message catalogs themselves, a runtime library supporting the retrieval of translated messages, and a few stand-alone programs to massage in various ways the sets of translatable strings, or already translated strings. A special GNU Emacs mode also helps interested parties in preparing these sets, or bringing them up to date.
*/
--with-mcrypt[=DIR]     Include mcrypt support
                        包含 mcrypt 支持
/**
This is an interface to the mcrypt library, which supports a wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes. Additionally, it supports RC6 and IDEA which are considered "non-free". CFB/OFB are 8bit by default.
*/
--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 共享内存支持
[永福原创]转载请注明:来自http://rickie622.blog.163.com
/**
Support for this functions are not enabled by default. To enable System V semaphore support compile PHP with the option --enable-sysvsem . To enable the System V shared memory support compile PHP with the option --enable-sysvshm . To enable the System V messages support compile PHP with the option --enable-sysvmsg .
*/
--with-gmp[=DIR]        Include GNU MP support
                        开启GNU MP支持
/**
GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.
The main target applications for GMP are cryptography applications and research, Internet security applications, algebra systems, computational algebra research, etc.
*/
--with-libxml-dir[=DIR]   LIBXML: libxml2 install prefix
                          LIBXML:libxml2的安装目录
--disable-phar          Disable phar support
/**
The phar extension provides a way to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation. In addition to providing this service, the phar extension also provides a file-format abstraction method for creating and manipulating tar and zip files through the PharData class, much as PDO provides a unified interface for accessing different databases. Unlike PDO, which cannot convert between different databases, Phar also can convert between tar, zip and phar file formats with a single line of code. see Phar::convertToExecutable() for one example.
What is phar? Phar archives are best characterized as a convenient way to group several files into a single file. As such, a phar archive provides a way to distribute a complete PHP application in a single file and run it from that file without the need to extract it to disk. Additionally, phar archives can be executed by PHP as easily as any other file, both on the commandline and from a web server. Phar is kind of like a thumb drive for PHP applications.
*/   
--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维护的一个包,所以报这个错误。
[永福原创]转载请注明:来自http://rickie622.blog.163.com
解决办法:
##因为开发中没有使用phar,所以连phar也一起关闭就可以了。
法1. 编译参数加上(--disable-phar),即:同时使用编译参数 --without-pear  --disable-phar   
法2. 两个(pear和phar)都不禁用。即:编译时,不对pear和phar做控制


  评论这张
 
阅读(1353)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018