php8.4.1: 配置php-fpm
一,配置php-fpm
/usr/local/soft/php8.4.1/etc$ vi php-fpm.d/www.conf
指定用户,和nginx保持一致
;user = nobody
;group = nobody
user = www-data
group = www-data
二,生成systemctl的service文件
1,复制
root@lhdpc:~# cd /usr/local/source/php/php-8.4.1/sapi/fpm
root@lhdpc:/usr/local/source/php/php-8.4.1/sapi/fpm# cp -axv php-fpm.service /lib/systemd/system/
'php-fpm.service' -> '/lib/systemd/system/php-fpm.service'
2,编辑:
# vi /lib/systemd/system/php-fpm.service
内容:
# ProtectSystem=full
ProtectSystem=false
三,启动
root@lhdpc:/usr/local/source/php/php-8.4.1/sapi/fpm# systemctl daemon-reload
root@lhdpc:/usr/local/source/php/php-8.4.1/sapi/fpm# systemctl start php-fpm.service
查看状态:
root@lhdpc:/usr/local/source/php/php-8.4.1/sapi/fpm# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php-fpm.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2024-12-17 11:49:05 CST; 6s ago
Main PID: 241173 (php-fpm)
Tasks: 3 (limit: 6956)
Memory: 8.0M
CGroup: /system.slice/php-fpm.service
├─241173 php-fpm: master process (/usr/local/soft/php8.4.1/etc/php-fpm.conf)
├─241175 php-fpm: pool www
└─241176 php-fpm: pool www
12月 17 11:49:05 lhdpc systemd[1]: Started The PHP FastCGI Process Manager.
查看端口:
# ss -lntp | grep php
LISTEN 0 4096 127.0.0.1:9000 0.0.0.0:* users:(("php-fpm",pid=241176,fd=9),("php-fpm",pid=241175,fd=9),("php-fpm",pid=241173,fd=7))
四,配置nginx访问:
root@lhdpc:/data/web/html# cd /etc/nginx/sites-enabled/
root@lhdpc:/etc/nginx/sites-enabled# vim php.conf
root@lhdpc:/etc/nginx/sites-enabled# more php.conf
server {
listen 80;
root /data/web/html;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
效果: