要在Ubuntu中更新PHP版本,您可以按照以下步骤操作:
首先,打开终端(快捷键:Ctrl + Alt + T)。
更新软件包列表:
sudo apt update
apt-cache policy php*
sudo apt install php7.4
sudo apt install php7.4-common php7.4-cli php7.4-fpm php7.4-json php7.4-opcache php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-pear php7.4-bcmath
php -v
这将显示已安装的PHP版本。如果需要,您还可以重启Web服务器以使更改生效。例如,如果您使用的是Apache,请运行:
sudo systemctl restart apache2
如果您使用的是Nginx,请运行:
sudo systemctl restart nginx
现在,您已成功更新了Ubuntu中的PHP版本。