旃麒雅 发表于 2018-11-11 14:31:09

web环境搭建之Linux--nginx-php-mysql

1.配置 ngingx :  

  
# nginx 的配置文件在 /etc/nginx/ 下 和 /etc/nginx/conf.d
  

  
(1)/etc/nginx/文件下的配置文件是 nginx.conf
  

  
#该配置文件不需要配置
  

  
#nginx.conf配置解释:http://blog.csdn.net/tjcyjd/article/details/50695922
  

  
(2) /etc/nginx/conf.d 下的配置文件 default.conf
  
    cd /etc/nginx/conf.d
  
    vim default.conf
  

  
server {
  
    listen       80;
  
    server_namelocalhost;
  

  
    #charset koi8-r;
  
    #access_log/var/log/nginx/log/host.access.logmain;
  

  
    location / {
  
      root   /usr/share/nginx/html;
  
      indexindex.html index.htm;
  
   #修改为:indexindex.html index.htm index.php;
  
    }
  

  
    #error_page404            /404.html;
  

  
    # redirect server error pages to the static page /50x.html
  
    #
  
    error_page   500 502 503 504/50x.html;
  
    location = /50x.html {
  
      root   /usr/share/nginx/html;
  
    }
  

  
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  
    #
  
    #location ~ \.php$ {
  
    #    proxy_pass   http://127.0.0.1;
  
    #}
  

  
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  
#nginx 不像Apache 它是将php文件交给php执行才能正常显示,通过上句可以它是通过 9000 端口发给PHP的
  
    #
  
    location ~ \.php$ {
  
      root         html;
  
      fastcgi_pass   127.0.0.1:9000;
  
      fastcgi_indexindex.php;
  
      fastcgi_paramSCRIPT_FILENAME   /script$fastcgi_script_name;
  
       #修改为:fastcgi_paramSCRIPT_FILENAME   /usr/share/nginx/html$fastcgi_script_name;
  
#/usr/share/nginx/html   为php文件所在地址
  
      include      fastcgi_params;
  
    }
  

  
    # deny access to .htaccess files, if Apache's document root
  
    # concurs with nginx's one
  
    #
  
    #location ~ /\.ht {
  
    #    denyall;
  
    #}
  
}
  

  
2.配置php-fpm :
  

  
#配置文件为: /etc/php-fpm.conf 和 /etc/php-fpm.d/www.conf
  

  
#因为其默认配置中监听的端口为 9000 所以不需要修改,可以直接使用


页: [1]
查看完整版本: web环境搭建之Linux--nginx-php-mysql