Last update at :2024-07-06,Edit by888u
Snail is in front\\"Methods for installing multiple PHP versions to coexist in LNMP one-click environment\\" article shared in the LNMP one-click environment. If you need to install multiple versions of PHP to coexist and different sites use different PHP versions, it is relatively simple. Yes, after installation, you can select the required PHP version when creating the site. In this article, Snail is going to take a look at how to install multiple versions of PHP in the OneinStack environment.
The same old question. If you are not familiar with the operation, it is recommended to back up the data first. If there is a snapshot backup server, you can back up the data, or back up the data locally. If there is a problem, you can have a way to restore it. In the demonstration of this article, Snail is used as a test machine, so there is no need to worry about losing data.
First, check the current PHP version
My current environment here is PHP5.5, and my test purpose is to install PHP7 to coexist with this version of PHP.
service php-fpm stop #Pause PHP
mv /etc/init.d/php-fpm{,_bk} #Backup startup script
Second, install PHP7
1. Modify the configuration file
/root/oneinstack/options.conf
Here we change the parameters after \\"php_install_dir\\" to \\"/usr/local/php7\\".
2. Install PHP7
./install.sh
Then perform the installation. Just install PHP7. Do not install anything else. Select n
It is installed automatically and then the installation is completed.
We don’t want to restart for now, we will restart later.
Third, modify the configuration file
1. Basic operations
service php-fpm stop #Stop php7 startup script mv /etc/init.d/php-fpm /etc/init.d/php7-fpm #Rename php7 startup script mv /etc/init.d/php- fpm_bk /etc/init.d/php-fpm #Restore php5 startup script
2. Set up startup
# CentOS:chkconfig –add php7-fpmchkconfig –add php-fpmchkconfig php7-fpm onchkconfig php-fpm on# Ubuntu/Debian:update-rc.d php7-fpm defaultsupdate-rc.d php-fpm defaults
3. Set up php7 environment listen
/usr/local/php7/etc/php-fpm.conf
Change listen = /dev/shm/php-cgi.sock to listen = /dev/shm/php7-cgi.sock.
Fourth, start PHP
service php-fpm start #Start php5service php7-fpm start #Start php7
Fifth, site allocation
Since we have PHP5 and PHP7 environments in our current server environment, how can we use them in different sites? In the .conf file of the current site, add:
fastcgi_pass unix:/dev/shm/php-cgi.sock;
Change to
fastcgi_pass unix:/dev/shm/php7-cgi.sock;
After modification and replacement, restart nginx to take effect.
It seems the method is feasible.
In summary, this is indeed a little more troublesome than LNMP configuration, and many require manual configuration files. Snail has proposed to the official to see if it can be changed to a more automated method similar to LNMP. This article has a reference: https://blog.linuxeye.cn/441.html. After practical testing, it is possible to achieve the co-existence of multiple PHPs.
Recommended site search: Which foreign server rental is good, server space rental, Korean server rental, distribution host, is there any charge for domain name registration, Ministry of Industry and Information Technology website registration system, icp registration, local ip query, google is permanently free Server, mainland China station group server,
发表评论