[nginx]: config php-fpm for nginx(config)
一、背景信息
1、服务器:rocky-9.3
[root@rocky:conf.d]# uname -a Linux rocky 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jan 8 17:35:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
2、nginx:
[root@rocky:conf.d]# nginx -v nginx version: nginx/1.20.1 [root@rocky:conf.d]#
3、php-fpm:
[root@rocky:conf.d]# php-fpm -v PHP 8.0.30 (fpm-fcgi) (built: Aug 3 2023 17:13:08) Copyright (c) The PHP Group Zend Engine v4.0.30, Copyright (c) Zend Technologies with Zend OPcache v8.0.30, Copyright (c), by Zend Technologies
二、配置文件(/etc/nginx/conf.d/php-for-nginx.conf)
[root@rocky:conf.d]# cat php-for-nginx.conf # config date: 2025-01-21 # # file_name = php-for-nginx.conf # # php-fpm: # -- version: PHP 8.0.30 (fpm-fcgi) (built: Aug 3 2023 17:13:08) # -- php-fpm.sock: /run/php-fpm/www.sock server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass unix:/run/php-fpm/www.sock ; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } [root@rocky:conf.d]# [root@rocky:conf.d]#
三、重启服务(nginx 和 php-fpm)
[root@rocky:conf.d]# cat nginx_reload #!/usr/bin/bash # reload nginx nginx -s reload # restart php-fpm systemctl restart php-fpm [root@rocky:conf.d]# [root@rocky:conf.d]#
四、参考资料:
1、 php 之 php-fpm 和 nginx结合使用 -- https://blog.csdn.net/qq_35720068/article/details/142105811
2、 什么是 PHP-FPM?一份深入浅出的指南 -- https://www.sysgeek.cn/what-is-php-fpm/
标签:rocky,fpm,root,nginx,conf,php,config From: https://www.cnblogs.com/lnlidawei/p/18684291