先去/usr/local目录下,新建php7bak,php8bak两个目录,假设当下默认安装的是php7,则将php8的目录复制到php8bak目录下备用。
shell脚本如下:
#!/bin/bash path7=/usr/local/php7bak path8=/usr/local/php8bak pid=empty if [ ! -d $path7/php ]; then echo 'Start converting php7 to php8..' if [ ! -d $path8/php ]; then echo 'error:php8 path is not exist'; exit 0; fi kill `cat /usr/local/php/var/run/php-fpm.pid` mv /usr/local/php $path7 mv $path8/php /usr/local else echo 'Start converting php8 to php7..' if [ ! -d $path7/php ]; then echo 'error:php7 path is not exist'; exit 0; fi kill `cat /usr/local/php/var/run/php-fpm.pid` mv /usr/local/php $path8 mv $path7/php /usr/local fi echo 'restart php..' /etc/init.d/php-fpm start echo 'finished~'
标签:php,path7,一键,lnmp,echo,usr,php7,local From: https://www.cnblogs.com/cx850116/p/17522724.html