您的位置:晶晶的博客>Linux>centos下服务器软件升级:nginx升级到nginx-1.4.1、php升级到5.3.25

centos下服务器软件升级:nginx升级到nginx-1.4.1、php升级到5.3.25

    手头一台服务器,采用nginx-1.2.3,本地测试nginx1.4.1搭配php5.3.25内存暂用率下降了不少,似乎与php-fpm有关,但考既然要升级php,顺便把nginx也升级到了最新稳定版。本次升级附带升级了部分已经提供了新版的lib库,故而相当于全新安装。

   nginx升级

   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 bzip2 bzip2-devel ncurses ncurses-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 make openssl*

    -------------------------------------------   

   2、GD库相关升级

    -------------------------------------------

    yum -y install gd gd2 gd-devel gd2-devel

    -------------------------------------------

    3、pcre正则匹配库升级

    -------------------------------------------

cd /usr/local/src 
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz 
./configure --prefix=/usr/local/pcre 
make && make install


    -------------------------------------------

    4、主角nginx升级安装 

    原先nginx安装在/usr/local/nginx 本次升级覆盖安装,覆盖前先备份整个目录(主要是网站配置文件的备份)

    经过测试,zlib库无需再使用指定zlib源代码的方式附加在nginx编译中,直接使用yum安装的系统zlib库

   

cd /usr/local cp -R nginx nginx-back 
cd /usr/local/src wget http://nginx.org/download/nginx-1.4.1.tar.gz 
tar zxvf nginx-1.4.1.tar.gz 
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.32 --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_mp4_module --with-http_flv_module 
cp -R /usr/local/nginx-back/conf /usr/local/nginx/conf 


    nginx升级完成,service nginx reload|restart nginx升级并启动完成

    测试nginx版本

    --------------------------------------------

    /usr/local/nginx/sbin/nginx -v

    --------------------------------------------

    点击查看原图

    php升级

    注意,原先版本的编译的扩展也需要重新编译

    1、php依赖库安装

    jpegsrc-v9安装,这个软件还不好找,本博客提供,信不过请绕道自查

    ------------------------------------------

    cd /usr/local/src

    wget http://blog.jjonline.cn/Upload/file/jpegsrc.v9.tar.gz

    tar zxvf jpegsrc.v9.tar.gz

    cd jpeg-9

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

    make && make install

    ------------------------------------------

    libpng安装

    -----------------------------------------

    cd ..

    wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz

    tar zxvf libpng-1.6.2.tar.gz

    cd libpng-1.6.2

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

    make && make install

    -----------------------------------------

    freetype安装

    -----------------------------------------

    cd ..

    wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz

    tar zxvf freetype-2.4.12.tar.gz

    cd freetype-2.4.12

    ./configure --prefix=/usr/local/libs  #此处可能提示“make: Nothing to be done for `unix'.” 直接make即可

    make && make install

    -----------------------------------------

    mhash、libmcrypt、mcrypt安装

    -----------------------------------------

    cd ..

    wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"

    wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"

    wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"

    

    tar zxvf libmcrypt-2.5.8.tar.gz

    cd libmcrypt-2.5.8

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

    make && make install

    cd libltdl/

    ./configure --prefix=/usr/local/libs --enable-ltdl-install

    make && make install


    cd ../../

     tar zxvf mhash-0.9.9.9.tar.gz

    cd mhash-0.9.9.9

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

    make && make install

    cd ..

    -----------------------------------------

    添加lib库查询变量

    -----------------------------------------

    vi /etc/ld.so.conf

    添加

    /usr/local/libs/lib

    启用

    ldconfig

    -----------------------------------------

    tar zxvf mcrypt-2.6.8.tar.gz

    cd mcrypt-2.6.8

    export LDFLAGS="-L/usr/local/libs/lib -L/usr/lib"

    export CFLAGS="-I/usr/local/libs/include -I/usr/include"

    ./configure --prefix=/usr/local/libs --with-libmcrypt-prefix=/usr/local/libs #此处若提示“You need at least libmhash 0.8.15 to compile this program.” 将上述安装mhash步骤中的--prefix参数去掉,编译到默认的/usr/local/lib中

    make && make install

    openssl升级

    cd ..

    wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz

    tar zxvf openssl-1.0.1e.tar.gz

    ./config --prefix=/usr/local/libs #命令比较特殊!!!!

    make && make install

    -------------------------------------------

    编译php

    -------------------------------------------

    编译前将原先的php备份

    某些找不到mysql相关lib的错误,请: 

    ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ #64位 

    ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/ #32位


    ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql 

    ln -s /usr/local/mysql/include/mysql /usr/include/mysql

    cp -R /usr/local/php /usr/local/php-back

    

    cd ..

    wget http://cn2.php.net/distributions/php-5.3.25.tar.gz

    tar zxvf php-5.3.25.tar.gz

    cd php-5.3.25

    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/addons --with-libxml-dir=/usr --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-iconv-dir --with-freetype-dir=/usr/local/libs --with-jpeg-dir=/usr/local/php/libs --with-png-dir=/usr/local/libs --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath -enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/usr/local/libs --with-gd --enable-gd-native-ttf --with-openssl=/usr/local/libs --with-mhash=/usr/local/libs --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap

    make

    make install

    -------------------------------------------

    最后复制php配置文件,并重新编译额外添加的模块,即可

    

    本文参照张工博客部分内容

转载请注明本文标题和链接:《centos下服务器软件升级:nginx升级到nginx-1.4.1、php升级到5.3.25

相关推荐

网友评论抢沙发

路人甲 表情
Ctrl+Enter快速提交