本文介绍在Debian 10(Buster)/Debian 9(Stretch)操作系统上安装PHP 7.4及在Nginx中使用PHP 7.4的方法。
在Debian 10/Debian 9上安装PHP 7.4 请按照下面介绍的步骤在Debian 10和Debian 9 Linux发行版上安装PHP 7.4,SURY PHP PPA信息库中提供了最新版本的Debian PHP,我们将添加该存储库作为先决条件,然后从其中在Debian 10/Debian 9上安装PHP 7.4,更新内容:PHP 7.4.0发布下载,附新特性及新功能介绍。 步骤1:更新系统 确保系统已更新: sudo apt update sudo apt upgrade -y && sudo reboot 步骤2:添加SURY PHP PPA存储库 将PPA存储库下载并存储在Debian Server/Desktop上的文件中,但首先,请下载GPG密钥: sudo apt -y install lsb-release apt-transport-https ca-certificates sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 然后添加存储库: echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list 步骤3:在Debian 10/Debian 9上安装PHP 7.4 最后一步是在Debian 10/Debian 9上安装PHP 7.4,在安装之前,更新添加的存储库上的系统软件包列表: sudo apt update 然后在Debian 10/Debian 9上安装PHP 7.4: sudo apt -y install php7.4 当提示完成在Debian 10/Debian 9 Linux系统上的PHP 7.4安装时,回答y,具体如下: Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libgdbm-compat4 libgdbm6 libjansson4 libldap-2.4-2 libldap-common liblua5.2-0 libnghttp2-14 libpcre2-8-0 libperl5.28 librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsodium23 libssh2-1 perl perl-modules-5.28 php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline psmisc ssl-cert Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make libb-debug-perl liblocale-codes-perl openssl-blacklist The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libgdbm-compat4 libgdbm6 libjansson4 libldap-2.4-2 libldap-common liblua5.2-0 libnghttp2-14 libperl5.28 librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsodium23 libssh2-1 perl perl-modules-5.28 php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline psmisc ssl-cert The following packages will be upgraded: libpcre2-8-0 1 upgraded, 36 newly installed, 0 to remove and 7 not upgraded. Need to get 15.0 MB of archives. After this operation, 76.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y 使用下一条命令安装其他软件包: sudo apt-get install php7.4-xxx 例如: sudo apt-get install php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip} 注:与Apache相关的PHP配置存储在/etc/php/7.4/apache2/php.ini中。
在Nginx中使用PHP 7.4 在Debian上安装php可以配置Apache,对于有兴趣运行Nginx和PHP的用户,需要停止并禁用Apache服务: sudo systemctl disable --now apache2 然后安装fpm extension和nginx软件包: sudo apt-get install nginx php7.4-fpm PHP FPM配置文件位于目录:/etc/php/7.4/fpm/。 Nginx和php-fpm服务应该正在运行: $ systemctl status php7.4-fpm nginx
至此,可以在Debian 10/Debian 9 Linux系统上使用PHP 7.4了。
相关主题 |