码迷,mamicode.com
首页 > Web开发 > 详细

php环境一键升级脚本

时间:2018-09-15 13:52:49      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:erro   soap   smi   php环境   check   系统   gcc   环境   lin   

  因为要解析PHP页面需要配置相应的PHP环境,而系统本身的php版本又大多不合适。网上那种一键lamp和lnmp的脚本很多,但是这样一来自己能够定制的空间则少了。所以我自己编写了个门用于安装php环境的脚本!

 

脚本内容:

  

#!/bin/bash

if [ $(id -u) != 0 ] ;then

        echo "ERROR: you must be root to run this script"

        exit 1

fi

read -p "Are you ready to installing the new PHP environment ?you can input ‘y|Y‘ to continue or ‘n|N‘ to exit." choice

case $choice in

[Yy])

echo "The setup program is preparing,please wait a minute........"

ping -c 4 museum.php.net &> /dev/null

if [ $? != 0 ];then

        echo "Can‘t connected to the internet or can‘t resolve domain name,please check your network"

        exit 2

fi

yum install epel-release -y

which wget &> /dev/null

if [ $? != 0 ];then

        echo "wget not exist,please install wget before install"

        exit 3

fi

while true;do

read -p "Please input which version of PHP do you want to install like x.x.x:" version

if [[ $version =~ ^[0-9]\.[0-9]\.[0-9]$ ]];then

        wget museum.php.net/php${version:0:1}/php-${version}.tar.gz

        if [ $? != 0 ] ;then

                echo "You choose a wrong version of PHP,please input another version for install^-^!"

                exit 8

        fi

        break

else

        echo "Please input correct version of number"

fi

done

echo "Start to installing dependent environment!"

        sleep 3

yum install  openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel  libtidy libtidy-devel  libicu-devel -y

tar -xf php-${version}.tar.gz

cd ./php-${version}

./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib -with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip  --enable-intl

make && make install

if [ $? == 0 ];then

cp php.ini-development /usr/local/php/lib/php.ini

sed -i ‘s/post_max_size.*/post_max_size = 16M/‘ /usr/local/php/lib/php.ini

sed -i ‘s/max_execution_time.*/max_execution_time = 300/‘ /usr/local/php/lib/php.ini

sed -i ‘s/max_input_time.*/max_input_time  = 300/‘ /usr/local/php/lib/php.ini

sed -i ‘s/;mbstring.func_overload = 0/mbstring.func_overload = 0/‘ /usr/local/php/lib/php.ini

sed -i ‘s/;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/‘ /usr/local/php/lib/php.ini

sed -i ‘s/;date.timezone.*/date.timezone = Asia\/Shanghai/‘ /usr/local/php/lib/php.ini

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

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

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

echo "export PATH=\$PATH:/usr/local/php/bin" >> /etc/profile

echo -e "php-${version} has been successfully installed!\nif you want import the php to environmental variables......\nplease executed the command 【source /etc/profile】"

cd ..

rm -rf php-${version}*

else

cd ..

rm -rf php-${version}*

echo -e "\033[5;31mCompilation install failed!\033[0m"

fi

;;

[Nn])

        echo "Install aborting!"

        exit 4

;;

esac

  

 

 

 

php环境一键升级脚本

标签:erro   soap   smi   php环境   check   系统   gcc   环境   lin   

原文地址:https://www.cnblogs.com/RottenLeaf/p/9650700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!