如何集成PHP-FPM与Nginx
2025-04-14
4
参考资料
安装PHP-FPM和Nginx
Ubuntu/Debian:
sudo apt install nginx php-fpm
CentOS/RHEL:
sudo yum install nginx php-fpm
配置PHP-FPM
编辑
/etc/php/{version}/fpm/pool.d/www.conf
确保监听方式:
listen = /run/php/php{version}-fpm.sock
配置Nginx
编辑站点配置文件
/etc/nginx/sites-available/example.com
添加PHP处理:
location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php{version}-fpm.sock; }
重启服务
sudo systemctl restart php{version}-fpm sudo systemctl restart nginx
测试配置
创建测试文件
/var/www/html/info.php
:
<?php phpinfo(); ?>
访问
http://server/info.php
验证
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。