在 Linux 下升级 PHP,可以按照以下步骤进行操作:
1、检查当前 PHP 版本:
打开终端,输入以下命令查看当前 PHP 版本:
“`
php v
“`
2、更新系统软件包:
运行以下命令更新系统软件包列表:
“`
sudo apt update
“`
3、安装依赖项:
运行以下命令安装升级 PHP 所需的依赖项:
“`
sudo apt install buildessential libxml2dev libssldev zlib1gdev libzipdev libcurl4openssldev libjpegdev libpngdev libfreetype6dev libonigdev libreadlinedev libsqlite3dev libmysqlclientdev phppear php7.4dev
“`
4、下载 PHP 源码:
访问 PHP 官方网站(https://www.php.net/downloads.php)下载最新版本的源代码压缩包,选择与您的 Linux 发行版和体系结构匹配的版本。
5、解压 PHP 源码:
将下载的压缩包解压到您选择的目录中,/usr/local/src
:
“`
tar zxvf phpx.y.z.tar.gz C /usr/local/src/
“`
x.y.z
是下载的 PHP 版本号。
6、进入 PHP 源码目录:
使用以下命令进入解压后的 PHP 源码目录:
“`
cd /usr/local/src/phpx.y.z/
“`
7、配置编译选项:
运行以下命令配置编译选项:
“`
./configure prefix=/usr/local/php withconfigfilepath=/usr/local/php/etc enablefpm withfpmuser=wwwdata withfpmgroup=wwwdata enablembstring withcurl withopenssl withzip withmysqli withpdo_mysql enablesoap enablesockets enablesysvsem enablesysvshm enablepcntl enableexif enablebcmath enablecalendar enableftp enableintl withgettext withgd withjpegdir=/usr/include/ withpngdir=/usr/include/ withfreetypedir=/usr/include/ withzlib withmcrypt enableopcache enablexmlreader enablexmlwriter enablesimplexml disablerpath enableshared=yes enablecli=yes
“`
根据您的需求,可以根据需要启用或禁用其他功能。
8、编译并安装 PHP:
运行以下命令开始编译和安装 PHP:
“`
make && make install
“`
这将花费一些时间来完成编译过程。
9、添加新 PHP 版本的软链接:
运行以下命令将新安装的 PHP 添加到系统的可执行路径中:
“`
echo "/usr/local/php/bin" | sudo tee a /etc/environment > /dev/null && source /etc/environment && echo "export PATH=$PATH:/usr/local/php/bin" | sudo tee a /etc/profile > /dev/null && source /etc/profile && sudo updatealternatives install /usr/bin/php php /usr/local/php/bin/php* 100 && sudo updatealternatives set php /usr/local/php/bin/php* && which php && ls l $(which php) && ls l $(which fpm) && ls l $(which cgi) && ls l $(which fastcgi) && ls l $(which phar) && ls l $(which shim) && ls l $(which composer) && ls l $(which opcache) && ls l $(which xdebug) && ls l $(which yac) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fpm) && ls l $(which fPMEngINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGINEeNGILEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEENEEGEE
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/553570.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复