简单的nginx fastcgi配置

本文介绍了如何配置Nginx以使用FastCGI处理PHP请求,包括设置监听端口、服务器名称、根目录、重写规则以及FastCGI的相关配置,确保正确处理静态文件和PHP文件的请求。
摘要由CSDN通过智能技术生成

注意index,try_files指令的用法

    server {

      listen 8803 default_server;
      server_name test.php.360.cn;


      root /data/www/test;
      index index.html index.htm index.php;
    
      location / { 
          try_files $uri $uri/ /index.php; #try_files 会自动去掉末尾的斜杠
      }    
    
      location ~ \.php$ {
         try_files $uri =404; #优化文件不存在的话提前报错, fascgi 404 File not found.
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
      }   

    }


server {
    listen 80; 


    server_name  yaf.com;


    root /home/acmer1183/yaf/public;


    index index.php index.html;
    
    access_log /data/nginx/logs/yaf.com.access.log;
    error_log  /data/nginx/logs/yaf.com.error.log;
    
    rewrite

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值