AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 795248
Accepted
Patrick
Patrick
Asked: 2016-08-07 08:16:56 +0800 CST2016-08-07 08:16:56 +0800 CST 2016-08-07 08:16:56 +0800 CST

Nginx 主脚本未知(fastcgi_param + 别名)

  • 772

我在服务器块中使用 Laravel,我想创建一个别名,例如 /webmail。这会导致 nginx " Primary script unknown" 错误。我想我需要改变我的fastcgi_param. 谁能帮我?

下面是关于我的 Nginx 服务器块的重要部分。

server {

    listen       80 default_server;
    server_name  _;

    set $root_path '/var/www/html/public';
    root $root_path;

    index index.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {

        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index /index.php;

        include /etc/nginx/fastcgi_params;

        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location /webmail {
        root /var/www/;
    }
}

所以我的网络邮件应用程序位于/var/www/webmail.

当我更改SCRIPT_FILENAME为:

fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;

但是,在此更改后,根域不再起作用。我无法将上面的行放在位置部分。

php fastcgi nginx
  • 1 1 个回答
  • 414 Views

1 个回答

  • Voted
  1. Best Answer
    Tero Kilkanen
    2016-08-07T10:08:49+08:002016-08-07T10:08:49+08:00

    试试这个配置:

    server {
    
        listen       80 default_server;
        server_name  _;
    
        set $root_path '/var/www/html/public';
        root $root_path;
    
        index index.php index.html index.htm;
    
        try_files $uri $uri/ @rewrite;
    
        location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/$1;
        }
    
        location ~ \.php {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index /index.php;
    
            include /etc/nginx/fastcgi_params;
    
            fastcgi_split_path_info       ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT   $root_path;
        }
    
        location /webmail {
            set $root_path '/var/www';
            root $root_path;
        }
    }
    

    因此,我们根据位置将不同的文档根/脚本文件名前缀传递给 PHP。$root_path在我们设置为的默认位置/var/www/html/public上,/webmail我们将其设置为/var/www.

    您可能需要在该位置添加一个单独的rewrite/try_files部分/webmail,以便index.php尝试使用该脚本或任何其他默认 webmail 条目脚本。为此,您需要查看您的网络邮件文档。

    • 0

相关问题

  • 用户特定的 Php.ini 当 php 作为模块运行时?

  • 使 php mail() 函数在 ubuntu-server 上工作的步骤是什么?

  • Web 服务器和数据库服务器位于完全不同的位置

  • PHP 作为 CGI 还是 Apache 模块?

  • 通过 VPN 连接什么是远程服务器 IP?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve