【一键脚本】【WP】【PHP5.6升级】【PHP7.3】】阿里云轻量应用服务器WordPress PHP5.6升级PHP7.3 一键脚本哦!

阿里云轻量应用服务器WordPress PHP5.6升级PHP7.3 一键脚本哦!

转载 ----------> WordPress轻量应用服务器升级PHP版本 <

*tip: 原博主有详细的脚本说明哦 ~~~~~~~~~~~~~~~*


亲测脚本用时15分钟,编译升级成功

*之前就在WP页面升级过WP 4.8 —> WP 5.0

服务器环境:CentOS 7.3 Apache2.4 PHP5.6 MySQL5.7 WordPress4.8.1


一. 新建一个 shell 文件并将“一键脚本”【Ctrl+C】进去, :wq 退出并保存
vim upgrade_php.sh
二. 给脚本添加执行权限(建议都在 root下进行哦~ )
chmod +x upgrade_php.sh
三. 执行脚本
./upgrade_php.sh
* *可以泡脚去了~~~~脚本大概用时10~20分钟*
##一键脚本
#!/bin/bash
WORKDIR=/tmp/
PHP73_DIR=/usr/local/php73
DEFAULT_SWAP=0

createSwap(){
  if [ `cat /proc/meminfo | grep SwapTotal | awk -F " " '{print $2}'` -ne 0 ]
  then
    return 0
  fi
  if [ `cat /proc/meminfo | grep MemTotal | awk -F " " '{print $2}'` -le 1048576 ]
  then
    echo "Mem lower than 1GB,creating swap..."
    dd if=/dev/zero of=/swap bs=1M count=2048
    mkswap -f /swap
    swapon /swap && echo "SWAP create success."
    DEFAULT_SWAP=1
  fi
}

installDependence(){
  yum install -y libxml2-devel openssl-devel  curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel xslt libxslt-devel
  yum update -y curl curl-devel
  yum remove -y libzip
}

compileLibzip(){
  echo "start install libzip."
  cd ${WORKDIR}
  if [ -f libzip-1.2.0.tar.gz ]
  then
    rm -rf libzip-1.2.0.tar.gz
  fi
  wget https://code.aliyun.com/yh11/download/raw/master/libzip-1.2.0.tar.gz
  tar -zxvf libzip-1.2.0.tar.gz
  cd libzip-1.2.0
  ./configure
  make && make install
  if [ $? -ne 0 ]
  then
    echo "libzip install failed."
    exit 127
  fi
  ln -s /usr/local/lib/libzip/include/zipconf.h /usr/local/include
}

installPHP(){
  echo "Install PHP 7.3"
  cd ${WORKDIR}
  if [ -f php-7.3.9.tar.gz ]
  then
    rm -rf php-7.3.9.tar.gz
  fi
  wget https://code.aliyun.com/yh11/download/raw/master/php-7.3.9.tar.gz
  tar -xvf php-7.3.9.tar.gz
  cd php-7.3.9
  ./configure --prefix=/usr/local/php73  --enable-soap --enable-cgi --with-mysql=/usr/local/mysql --with-mysqli=mysqlnd --with-gd --with-pdo-mysql=mysqlnd --with-zlib --enable-zip --enable-fpm --without-pear --disable-phar --with-openssl --enable-mbstring=all --with-jpeg-dir=/usr --with-png-dir=/usr --with-curl --with-freetype-dir=/usr --enable-gd-native-ttf --with-xsl=/usr --enable-calendar --enable-exif --enable-ftp --with-iconv --enable-bcmath --with-mcrypt=/usr/local/libmcrypt --enable-opcache
  make && make install
  if [ $? -ne 0 ]
  then
    echo "PHP install failed."
    exit 127
  fi
  cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm73
  cp ${PHP73_DIR}/etc/php-fpm.conf.default ${PHP73_DIR}/etc/php-fpm.conf
  chmod +x /etc/init.d/php-fpm73
}

createConfig(){

cat << EOF > ${PHP73_DIR}/etc/php-fpm.d/www.conf
[www]
listen = /home/www/logs/php73-fpm.sock
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 128
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 15
pm.max_requests = 300
rlimit_files = 1024
slowlog = /home/www/logs/php73-fpm-slow.log
EOF

}

modifyApache(){
  sed -i 's#ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/home/www/logs/php-fpm.sock|fcgi://127.0.0.1/home/www/htdocs#ProxyPassMatch ^/(.*\\.php(/.*)?)$ unix:/home/www/logs/php73-fpm.sock|fcgi://127.0.0.1/home/www/htdocs#g' /usr/local/apache/conf/httpd.conf
}

restartService(){
  chkconfig php-fpm off
  chkconfig php-fpm73 on
  /etc/init.d/php-fpm stop
  /etc/init.d/php-fpm73 start
  /etc/init.d/apachectl restart
}

delSwap(){
  if [ ${DEFAULT_SWAP} -eq 1 ]
  then
    swapoff /swap
    rm -rf /swap
  fi
}

createSwap
installDependence
compileLibzip
installPHP
createConfig
modifyApache
restartService
delSwap
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值