为了账号安全,请及时绑定邮箱和手机立即绑定

PHP5.5降版本到5.4.45

标签:
PHP

2015.10.8 

PHP5.5降版本到5.4.45

主管找到我,开发发现PHP5.5不支持某些插件,具体不懂开发的东西

需要把PHP降级到5.4.45


OK,开始研究

1、首先降级肯定要停网站,报给主管

2、肯定不能用YUM,需要自己编译安装

3、备份是必须要先做的


OK,那先备份吧

都需要备份什么呢

MYSQL数据库、PHP配置文件、网站文件

一定有人说了,需要备份这么多吗

就怕万一啊,万一服务器磁盘坏了你找谁,找谁也没用的


1、数据库备份,这是我喜欢的备份命令

mysqldump -uroot -p密码 数据库名 >/root/back/数据库名-时间.sql

2、 网站文件

tar  –zcvf  kevin-时间.tar.gz  /opt/kevin

3、 nginx配置文件

tar  –zcvf  nginxconf-时间.tar.gz  /usr/local/nginx/conf/、

我是K哥!

4、 php配置文件

tar  –zcvf  php-fpm.d-时间.tar.gz /etc/php*  

/etc/php* 中包括 php.ini文件 php-fpm.d目录

tar -zcvf php-fpm.conf-时间.tar.gz /usr/local/php/etc/php-fpm.conf

OK,自行FTP下载


删除PHP5.5

先用YUM删吧

yum remove php*

看看还有PHP的什么东西吗

rpm -qa |grep php

如果有残留-e删除

rpm –e php-


1、安装PHP5.4

安装各种插件

yum install ncurses-devel libxml2-develbzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-develnet-snmp-devel gcc gcc-c++

 

2、安装mysql开发

rpm –qa |grep mysql

wget  ftp://bo.mirror.garr.it/pub/1/slc/updates/slc6X/x86_64/RPMS/mysql-devel-5.1.69-1.el6_4.x86_64.rpm

rpm –ivh mysql-devel-5.1.69

 

3、安装libmcrypt-2.5.7.tar.gz

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz

tar xzvf libmcry*
cd libmcry*

./configure

make

make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make

make install

我是K哥!

ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so


4、安装ZendGuardLoader

wget http://blog.ich8.com/wp-content/uploads/2013/06/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz

tar –zxvf  ZendGuardLoader

mv ZendGuardLoader.so /usr/local/php/modules/


5、配置PHP支持 Zend Guard Loader

如果你备份了php.ini那么不需要配置了,如果你是新安装就编辑吧

编辑php.ini(/etc/php.ini )文件,在最后位置添加以下内容:

[Zend Guard]

zend_extension=/usr/local/zend/ZendGuardLoader.so

; Enables loading encoded scripts. The default value is On

zend_loader.enable=1


6、创建PHP-fpm用户和组,我这里是apache:www

这后面涉及到网站文件安全,会有新博文讲网站安全

groupadd www

useradd apache -g www


7、编译安装

FTP上传PHP5.4.tar.gz,或者直接wget,我是因为很多台服务器,所以用的FTP

tar -zxvf PHP5.4.tar.gz

cd PHP5.4

我是K哥!

./configure --prefix=/usr/local/php --with-config-file-path=/etc \

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

--with-pdo-mysql=/usr/bin/mysql --with-iconv-dir=/usr/local --enable-fpm \

--disable-phar --with-fpm-user=apache \

--with-fpm-group=www --with-pcre-regex \

--with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir \

--enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir \

--enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt \

--enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets --enable-zip  --enable-cli --enable-pdo \

--enable-bcmath --with-snmp --disable-ipv6 --enable-mbregex --enable-soap


make

make install


8、恢复php配置文件

FTP上传之前备份的配置文件

cp php.ini /etc/php.ini

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

cp php-fpm.d /etc/


我是K哥!


9、启动PHP-FPM,检查并重启nginx

/usr/local/php/sbin/php-fpm

/usr/local/nginx/sbin/nginx –t

/usr/local/nginx/sbin/nginx -s reload


10、赠送环节,如果觉得命令麻烦,不如把PHP加入自启动

配置PHP-FPM开机自启动

vi /etc/init.d/php-fpm

一般没有这个文件,直接vi创建就好,复制下面的命令到文件中


#!/bin/bash

#

# Startup script for the PHP-FPM server.

#

# chkconfig: 345 85 15

# description: PHP is an HTML-embedded scripting language

# processname: php-fpm

# config: /usr/local/php/etc/php.ini

 

# Source function library.

. /etc/rc.d/init.d/functions

 

PHP_PATH=/usr/local

DESC="php-fpm daemon"

NAME=php-fpm

# php-fpm路径

DAEMON=$PHP_PATH/php/sbin/$NAME

# 配置文件路径

CONFIGFILE=$PHP_PATH/php/etc/php-fpm.conf

# PID文件路径(在php-fpm.conf设置)

PIDFILE=/var/run/php-fpm/php-fpm.pid

SCRIPTNAME=/etc/init.d/$NAME

 

# Gracefully exit if the package has been removed.

test -x $DAEMON || exit 0

 

rh_start() {

  $DAEMON -y $CONFIGFILE || echo -n " already running"

}

 

rh_stop() {

  kill -QUIT `cat $PIDFILE` || echo -n " not running"

}

 

rh_reload() {

  kill -HUP `cat $PIDFILE` || echo -n " can't reload"

}

 

case "$1" in

  start)

        echo -n "Starting $DESC: $NAME"

        rh_start

        echo "."

        ;;

  stop)

        echo -n "Stopping $DESC: $NAME"

        rh_stop

        echo "."

        ;;

  reload)

        echo -n "Reloading $DESC configuration..."

        rh_reload

        echo "reloaded."

  ;;

  restart)

        echo -n "Restarting $DESC: $NAME"

        rh_stop

        sleep 1

        rh_start

        echo "."

        ;;

  *)

         echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2

         exit 3

        ;;

esac

exit 0



11、编辑好后保存,执行以下命令


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

chkconfig php-fpm on



12、完成!可以使用以下命令管理php-fpm了


service php-fpm start

service php-fpm stop

service php-fpm restart


13、验证操作

打开所有网站检查,并查看PHP日志文件








点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消