如何集成PHP-FPM与Nginx
                2025-04-14 14:15:45
                74
            
        参考资料
如何集成PHP-FPM与Nginx
- 安装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验证

