参考资料

  1. php服务器搭建软件详细说明以及案例
  2. php服务器是什么详细说明以及案例
  3. 配置 PHP-FPM
  4. 宝塔面板安装redis
  5. php服务器性能优化详细说明以及案例
  6. 宝塔面板安装方法
  7. php服务器软件详细说明以及案例
  8. php服务器管理工具详细说明以及案例
  1. 安装PHP-FPM和Nginx

  • Ubuntu/Debian: sudo apt install nginx php-fpm

  • CentOS/RHEL: sudo yum install nginx php-fpm

  1. 配置PHP-FPM

  • 编辑/etc/php/{version}/fpm/pool.d/www.conf

  • 确保监听方式: listen = /run/php/php{version}-fpm.sock

  1. 配置Nginx

  • 编辑站点配置文件/etc/nginx/sites-available/example.com

  • 添加PHP处理:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php{version}-fpm.sock;
}
  1. 重启服务

sudo systemctl restart php{version}-fpm
sudo systemctl restart nginx
  1. 测试配置

  • 创建测试文件/var/www/html/info.php:

<?php phpinfo(); ?>
  • 访问http://server/info.php验证