在CentOS上切换PHP版本常用方法如下:
sudo yum install epel-release
,sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
。sudo yum-config-manager --enable remi-php80
。sudo yum remove php*
。sudo yum install php
。sudo systemctl restart httpd
(Apache)或sudo systemctl restart nginx
(Nginx)。curl -L -O https://github.com/philcook/phpswitch/releases/download/0.4.0/phpswitch-0.4.0.phar
,chmod +x phpswitch-0.4.0.phar
,sudo mv phpswitch-0.4.0.phar /usr/local/bin/phpswitch
。phpswitch install 7.4
。phpswitch use 7.4
。sudo yum install -y gcc make zlib-devel libxml2-devel openssl-devel
等。wget https://www.php.net/distributions/php-7.4.33.tar.gz
。tar -zxvf php-7.4.33.tar.gz
,cd php-7.4.33
,./configure
,make
,sudo make install
。/etc/profile
添加export PATH=/usr/local/php/bin:$PATH
,然后source /etc/profile
。