【问题标题】:nginx+php-fpm issue not able to call other php files in foldernginx+php-fpm 问题无法调用文件夹中的其他 php 文件
【发布时间】:2016-02-07 07:06:07
【问题描述】:

我有一个 nginx 和 php-fpm 配置,但是当我从浏览器访问它时,只有 index.php 正在执行,但我无法调用其余文件。

nginx 配置

{
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    use epoll;
    multi_accept on;
}

http {
keepalive_timeout 15;
    keepalive_requests 2048;
    server_tokens off;

   upstream php
{
    server unix:/tmp/php-cgi.socket;
   server serverip:9000;
}

 access_log  /var/log/nginx/access.log  main;
include /etc/nginx/conf.d/*.conf;

}

在 /etc/nginx/conf.d/ 中配置

    server {

        root /var/www/Cachet/public/;
       location / {
     try_files $uri $uri/ /index.php index.php;
    }
        server_name  serverip ; # Or whatever you want to use
        listen 80 default;
        location ~* \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_keep_conn on;
                    include fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }




}

这些是 error.log 和 access.log 中的几行

2015/11/06 12:40:53 [错误] 19346#0: *1 FastCGI 在标准错误中发送: “无法打开主脚本:/var/www/Cachet/public/dashboard.php (没有这样的文件或目录)”,同时从 上游,客户端:客户端 IP,服务器:服务器 IP,请求:“GET /dashboard.php HTTP/1.1”,上游: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "服务器IP"

2015/11/06 12:41:05 [错误] 19346#0: *1 FastCGI 在标准错误中发送: “无法打开主脚本:/var/www/Cachet/public/autoload.php (没有这样的文件或目录)”,同时从 上游,客户端:客户端 IP,服务器:服务器 IP,请求:“GET /autoload.php HTTP/1.1",上游: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "服务器IP"

【问题讨论】:

    标签: php nginx


    【解决方案1】:

    因为这里没有响应,所以在我同事的帮助下,我能够在配置文件中找到两个问题,因为我无法在单独的文件夹中调用多个 php 文件..

    try_files $uri $uri/ /index.php index.php; 
    instead it needed 
    try_files $uri $uri/ /index.php$is_args$args;
    

    由于它没有加载图像,因此缺少的行是 包括/etc/nginx/mime.types;在 conf.d/default.conf 的位置块中。

    【讨论】:

      猜你喜欢
      • 2022-01-03
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 2013-02-06
      • 2014-08-04
      相关资源
      最近更新 更多