Install the paths of each version of PHP plus the version number
such as--prefix=/usr/local/php-7.0.1
As below, I install the path
When installing, add each version of PHP-FPM to the service
Install-v-m755/php Source Path/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm (corresponding version number)
The easiest way to switch is to start a different service.
Turn off the corresponding T version of PHP-FPM first.
sudo service php-fpmxxxx stop
Turn on the version you want to switch
sudo service php-fpm7.0.5 start
The second way to use the script to switch
Copy a php-fpm startup script
sudo cp/etc/init.d/php-fpm7.0.5/etc/init.d/php-fpm
Use Vim to open, change prefix to prefix=/usr/local/php
The main thing here is to make a shortcut to the version of PHP that was launched.
Create a new script in the home directory switchphp.sh
#!/bin/zsh
version= ($ ls/usr/local | grep php-| awk ' {printf '%s ', '} '))
echo $version
echo "Please enter the right version This number: "
i=1 for
ver in $version
does
echo $i") "$ver
i=$ (($i + 1))
done
Read num case
" $ Num "
in [1234])
echo the version you selected is: $version [$num]
service php-fpm stop
ln-sf/usr/local/$version [$num ]/usr/local/php
If ["$?"!= 0]; then
echo "has no permissions failed"
exit 1
fi
service php-fpm start
If ["$?"!= 0]; Then
echo "No permissions Failed"
exit 1
fi
echo "successfully switched"
;;
*
Echo-n "The version number you entered is not correct. "
;;
Esac
Version= ($ (ls/usr/local | grep php-| awk ' {printf '%s ', $} ')
Pay attention to this sentence, according to the existing installation directory to modify
Modify the switchphp.sh into an executable file
sudo chmod 755 switchphp.sh
And then execute
sudo./switchphp.sh
The effect chart is as follows: