安装环境
root@localhost:~# cat /etc/debian_version
11.8
root@localhost:~# uname -a
Linux localhost 5.10.0-17-cloud-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 GNU/Linux
依赖安装
这里安装了不少东西,主要是PHP扩展依赖,实际上等编译完成之后可以移除。
apt-get update
apt-get install build-essential libssl-dev libcurl4-openssl-dev libonig-dev libxml2-dev libzip-dev libsodium-dev libsctp-dev libfreetype-dev libbrotli-dev libssh2-1-dev libjpeg-dev libsqlite3-dev libwebp-dev libpng-dev libsystemd-dev pkg-config -y
编译安装
wget https://www.php.net/distributions/php-8.2.12.tar.gz
tar -zxvf ./php-8.2.12.tar.gz
cd php-8.2.12
./configure --prefix=/usr/local/php82 --with-config-file-path=/usr/local/php82/etc --enable-fpm --with-fpm-user=caddu --with-fpm-group=caddy --with-fpm-systemd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-freetype --with-jpeg --with-zlib --enable-xml --with-libxml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-sodium --with-webp
make
make install
PHP-FPM配置
建立保存文件:/usr/lib/systemd/system/php-fpm-82.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/usr/local/php8.1/var/run/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
建立保存文件:/usr/local/php82/etc/php-fpm.conf
[global]
pid = /var/run/php-fpm-82.pid
error_log = /var/log/php-fpm-82.log
log_level = debug
[caddy]
listen = 127.0.0.1:9000
listen.backlog = 8192
listen.allowed_clients = 127.0.0.1
listen.owner = caddy
listen.group = caddy
listen.mode = 0666
user = caddy
group = caddy
pm = dynamic
pm.status_path = /phpfpm_82_status
pm.max_children = 150
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30
request_terminate_timeout = 100
request_slowlog_timeout = 30
slowlog = var/log/php-fpm-slow.log
配置自启:systemctl enable php-fpm-82 && systemctl start php-fpm-82