首页云计算 正文

PHP一键升级脚本

2024-11-19 5 0条评论
  1. 首页
  2. 证书相关
  3. PHP一键升级脚本

PHP一键升级脚本

发布日期:2017-03-03

PHP一键升级脚本截取《lnmp最新源码一键安装包》中upgrade_php.sh,防止大版本之间兼容问题,只提供同一大版本之间的升级,如:php-5.3.10升级到php-5.3.27,php-5.4.10升级到php-5.4.21,不能跨版本从php-5.3升级到最新php-5.4.21

PHP一键升级脚本内容如下(cat upgrade_php.sh):

#!/bin/bash
# Author:  yeho <lj2007331 AT gmail.com>
# Blog:  //blog.trustauth.cn

# Check if user is root
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1 

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
echo "#######################################################################"
echo "#         LNMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+          #"
echo "#                    Upgrade PHP for LNMP                             #"
echo "# For more information Please visit //blog.trustauth.cn/31.html  #"
echo "#######################################################################"

cd src
. ../options.conf
[ ! -e "$php_install_dir" ] && echo -e "\033[31mThe PHP is not installed on your system!\033[0m " && exit 1

get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}

echo
Old_php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
echo -e "Current PHP Version: \033[32m$Old_php_version\033[0m"
while :
do
        echo
        read -p "Please input upgrade PHP Version: " php_version
        if [ "${php_version%.*}" == "${Old_php_version%.*}" ]; then
                if [ "${php_version##*.}" -gt "${Old_php_version##*.}" ]; then
                        [ ! -e "php-$php_version.tar.gz" ] && wget -c http://www.php.net/distributions/php-$php_version.tar.gz > /dev/null 2>&1
                        if [ -e "php-$php_version.tar.gz" ];then
                                echo -e "Download \033[32mphp-$php_version.tar.gz\033[0m successfully! "
                        else
				echo -e "\033[31mIt does not exist!\033[0m"
                        fi
			break
                else
                        echo -e "Error: You must input PHP version greater than \033[32m$Old_php_version\033[0m!! "
                fi
        else
                echo -e "\033[31minput error!\033[0m Please only input '\033[32m${Old_php_version%.*}.xx' \033[0m"
        fi
done

if [ -e "php-$php_version.tar.gz" ];then
        echo -e "\033[32mphp-$php_version.tar.gz\033[0m [found]"
        echo "Press Ctrl+c to cancel or Press any key to continue..."
        char=`get_char`
        tar xzf php-$php_version.tar.gz
        cd php-$php_version
	make clean
        $php_install_dir/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash
        make ZEND_EXTRA_LIBS='-liconv'
        make install
	cd ..
        echo "Restarting php-fpm..."
        /etc/init.d/php-fpm restart
        echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_php_version\033[0m to \033[32m$php_version\033[0m"
fi
标签: linux 运维教程

上一篇:(总结)Mysql日期函数、时间函数

下一篇:MySQL/MariaDB/Percona数据库升级脚本

相关新闻

  • SSL证书对网站访问速度有影响吗
  • 个人隐私数据泄露有哪些危害?如何预防?
  • 部署SSL证书有哪些常见的错误
  • 国际证书、国产证书和国密证书
  • 游戏开发为什么离不开代码签名?
  • 僵尸网络攻击手法与防范方式
  • SSL证书助力保障网络数据安全
  • 网站加密与不加密区别
  • SSL证书有哪些类型和价格差异
  • ca机构颁发的证书包括那些内容呢?
文章版权及转载声明

本文作者:admin 网址:http://news.edns.com/post/112567.html 发布于 2024-11-19
文章转载或复制请以超链接形式并注明出处。

取消
微信二维码
微信二维码
支付宝二维码