搜ijsio 发表于 2018-12-18 10:00:44

配置nginx支持php

配置nginx支持php
vi /usr/local/nginx/conf/nginx.conf      #编辑配置文件
user   wwwwww;          #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
php-fpm.conf下的用户

indexindhttp://s3.运维网.com/wyfs02/M01/75/0B/wKioL1YxkSXgNrjRAAKT19iIJ4Y018.jpgex.phpindex.html index.htm;    #添加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
  location / {
  root   html;
  indexindex.html index.htm;
  }
  location ~ \.php$ {
  

  root /usr/local/nginx/html/;   ##切记要加绝对路径
  fastcgi_pass 127.0.0.1:9000;
  

  fastcgi_index index.php;
  

  fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;   ##切记要加绝对路径
  

  include fastcgi_params;
  

  }


最后检查php和nginx启动的用户是否都为www,如无问题重启服务,web访问测试



php-cgi -b 127.0.0.1:9000 -c /usr/local/php5/etc/php.ini       #php配置文件的路径
/etc/init.d/nginx restart#重启nginx
  




页: [1]
查看完整版本: 配置nginx支持php