mac下配置laravel环境各种问题 laravel nginx 配置

在centos上成功编译安装nginx 1.4、php 5.4并成功启动nginx和php-fpm后,访问php提示"File not found.",同时在错误日志中看到:

代码如下:

2013/10/22 20:05:49 [error] 12691#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.168.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.168.133"

错误解决方法:
在Nginx配置文件中找到定义调用脚本文件的地方,如:

代码如下:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;


修改成如下方式($document_root):

代码如下:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

提示:
$document_root 代表当前请求在root指令中指定的值。如:

代码如下:

location / {
       root   /usr/local/nginx/html;
       index  index.php index.html index.htm;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

上面配置中的$document_root就是针对/usr/local/nginx/html目录下的php文件进行解析。

之前一直nginx加载的是初始化的html目录,没有加载我指定的项目目录,各种网上查找问题,以为是项目代码问题,又下载了laravel源码测试了下还是那样,修改了php-fpm的加载方式tcp为socket 还是不行

后来我都想下载docker安装环境了,一想下载太慢就放弃了,还好最后调试了出来正常了,直接贴代码吧

server {
      listen 80;
      server_name www.crm_test.com;
      root /app/test/crm/public;

      add_header X-Frame-Options "SAMEORIGIN";
      add_header X-XSS-Protection "1; mode=block";
      add_header X-Content-Type-Options "nosniff";

      index index.html index.htm index.php;

      charset utf-8;

      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }

      location = /favicon.ico { access_log off; log_not_found off; }
      location = /robots.txt  { access_log off; log_not_found off; }

      error_page 404 /index.php;

      location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          include /usr/local/etc/nginx/fastcgi.conf;
          fastcgi_intercept_errors on;
          fastcgi_pass  127.0.0.1:9000;
      }

      location ~ /\.(?!well-known).* {
          deny all;
      }
  }

 

 

转载于:https://my.oschina.net/shunshun/blog/3013200

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值