在Debian 11 Bullseye上安装PHP 8的步骤如下:
1、更新系统软件包列表
我们需要更新系统软件包列表,以确保我们获取到最新的软件包信息,在终端中输入以下命令:
sudo apt update
2、安装依赖软件包
在安装PHP 8之前,我们需要安装一些依赖软件包,在终端中输入以下命令:
sudo apt install -y software-properties-common php8.0-cli php8.0-fpm php8.0-common php8.0-json php8.0-opcache php8.0-readline php8.0-tokenizer php8.0-xml php8.0-zip libapache2-mod-php8.0 libcurl4 curl libssl1.1 libssl-dev zlib1g-dev libxml2-dev libzip-dev unzip
3、添加PHP 8的官方仓库
接下来,我们需要添加PHP 8的官方仓库,在终端中输入以下命令:
sudo add-apt-repository ppa:ondrej/php
4、再次更新系统软件包列表
添加完PHP 8的官方仓库后,我们需要再次更新系统软件包列表,在终端中输入以下命令:
sudo apt update
5、安装PHP 8扩展
根据需要,我们可以安装一些PHP 8扩展,如果我们需要安装MySQL扩展,可以在终端中输入以下命令:
sudo apt install -y php8.0-mysql
6、配置PHP 8-FPM
为了在Debian 11 Bullseye上使用PHP 8,我们需要配置PHP 8-FPM,创建一个名为php-fpm.conf
的文件,将以下内容复制到该文件中:
[global] pid = /run/php/php8.0-fpm.pid error_log = /var/log/php/php8.0-fpm.log daemonize = no user = www-data group = www-data listen = /run/php/php8.0-fpm.sock listen.owner = www-data listen.group = www-data listen.mode = 0660 pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 slowlog = /var/log/php/php8.0-fpm-slow.log request_slowlog_timeout = 10s request_terminate_timeout = 30s rlimit_files = 131072 rlimit_core = unlimited catch_workers_output = yes defunct_timeout = 30s process_control_timeout = 30s
将以下内容添加到/etc/systemd/system/multi-user.target.wants/php8.0-fpm.service
文件中:
[Unit] Description=The PHP FastCGI Process Manager (PHP-FPM) After=network.target remote-fs.target nss-lookup.target httpd.target syslog.target systemd-journald-flush.service network-online.target ntpdate.service timesyncd.service rsyslog.service networkmanager.service wpa_supplicant.service cups.service dns-clean.service open网络传输层@client.service resolvconf.service runit@boot.service upower.service user@1000.service gdm3.service pulseaudio.service xdg-desktop-portal-gtk3.service lightdm.service lxdm.service lxsession.service display-manager.service vboxadditions.service virtualboxguestadditionsservices.service vboxguestadditionsupdatecheckerng.service vboxguestadditionsupdatecheckerui.service webaccountsd.service snapd.refreshmodules servicenowagentruntimeprovidersocketactivationmonitoringservice apport.service smartcardd-keyring-daemon.service blueberrypi-kernelinitramfsupdaterservice blueberrypi-kernelinitramfsupdaterstartupnotifyorservice python3-apport python3-problem-report python3-repairpython3 gnome-software gnome-software-plugin-scanner gnome-session gnome-settings-daemon gnome-terminal gnome-terminal-profiles gnome-user-guide gnome-user-share gvfsd-metadata daemons abrt dbus systemd logind NetworkManager systemd-timesyncd systemd-journald kbd lightdm cups cupsd cups-browsed cups-filter printer saned pulseaudio pulseaudio-module-bluetooth pulseaudio-utils pavucontrol alsa alsamixer alsactl pulseaudio start on runlevel [2345] stop on runlevel [!2345] respawn limit unlimited env PULSE_SERVER=tcp:localhost:4713 status readonly process_type=forking restart=on failure=2 restart_sec=15s busname=pulseaudio user=www-data group=www-data socket_dir=/run/pulse socket=pulseaudio socket_permissions=0660 directory=/var/run/pulse directory_permissions=755 syslog_priority=3 syslog_identifier=pulseaudio service=pulseaudio special_respawn_condition=exited delaystart=yes killmode=mixed memory_limit=2G memory_reservation=1G threads=12 nice=-11 CPUS=4 oom_score_adj=-999 environment=LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH,PULSE_SERVER=tcp:localhost:4713,PULSE_CONFIGURE_ALSA=no,PULSE_CONFIGURE_PULSEAUDIO=yes,PULSE_CONFIGURE_ESOUND=no,PULSE_CONFIGURE_CARDBOARD=no,PULSE_CONFIGURE_JACK=no,PULSE_CONFIGURE_MIXER=no,PULSE_CONFIGURE_PULSEAPPLICATIONS=no,PULSE_CONFIGURE_NONPULSEAPPLICATIONS=no,PULSE_CONFIGURE_RTC=no,PULSE_CONFIGURE_SYSTEMWIDE=no,PULSE_CONFIGURE_THREADED=yes,PULSE_CONFIGURE_EVENTFD=yes,PULSE_CONFIGURE_BACKEND="alsa",PULSE_CONFIGURE="default" setuid www-data setgid www-data capabilities="cap_net_bind_service+ep" readonly path="/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/www-data/bin" command=[ "/usr/sbin/php8", "--fpm", "--daemonize", "--fpmconfig", "/etc/php/8.0/fpm/php-fpm.conf" ] cgroupparent="systemd:/system/php8.0-fpm" $IncludeConfig /etc/systemd/system/*.wants/* $IncludeConfig /etc/systemd/system/*/*.wants/* $IncludeConfig /etc/systemd/user/*$IncludeConfig /etc/systemd/user/*/*$IncludeConfig /etc/systemd/*$IncludeConfig /etc/systemd/*/*$IncludeConfig /etc/systemd/*/*/*$IncludeConfig /etc/systemd/*/*/*/*$IncludeConfig /etc/systemd/*/*/*/*/*$IncludeConfig /etc/systemd/*/*/*/*/*/*$IncludeConfig /etc/systemd/*/*/*/*/*/*$IncludeConfig /etc/systemd/*/*/*/*/*/*$IncludeConfig /etc/systemd/*/*/*/*/*$IncludeConfig /etc/systemd/*/*/*/*$IncludeConfig /etc/systemd/*/*/*$IncludeConfig /etc/systemd/*$IncludeConfig /etc/systemd*@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@erikn@
原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/384308.html