简体   繁体   English

nginx:php-fpm 正在启动主网站,但不是第二个网站

[英]nginx: php-fpm is kicking in for main website, but not second site

I have two web folders:我有两个网络文件夹:

 /var/www/mainapplication.com/public
 /var/www/helpsystem

they are both PHP sites.它们都是 PHP 站点。 From the main application, you can click on a "help" button that links to https://mainapplication.com/help.php在主应用程序中,您可以单击链接到https://mainapplication.com/help.php的“帮助”按钮

Problem:问题:

Right now, when someone clicks on the help button, the tries to download the file help.php.现在,当有人单击帮助按钮时,会尝试下载文件 help.php。

Code:代码:

/var/www/mainapplication.com/help.php looks like this in part: /var/www/mainapplication.com/help.php 部分如下所示:

 $url = https://mainapplication.com/help/index.php
 $header("Location:$url");

The nginx conf file looks like this: nginx conf 文件如下所示:

server {
        listen 443 ssl;
        root /var/www/mainapplication.com/public;
        server_name mainapplication.com;

        ssl_certificate /etc/ssl/a/bundle.crt;
        ssl_certificate_key     /etc/ssl/a/a.key;
        ssl_protocols   TLSv1.2;

        error_log /var/log/nginx/mainapplication_com.log warn;
        index login.php;

        location / {
                allow all;
                try_files $uri $uri/ /=404;
        }

        location ^~ /help {
                alias /var/www/helpsystem;
                try_files $uri $uri/ /=404;
        }

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;                  
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

It seems the php section is not working for the help system, although it is for the main site. php 部分似乎不适用于帮助系统,尽管它适用于主站点。 Any tips would be appreciated.任何提示将不胜感激。 right now I'm trying to switch between the alias command and another root command.现在我正在尝试在 alias 命令和另一个 root 命令之间切换。

EDIT 1编辑 1

when I change the nginx conf to look like this:当我将 nginx conf 更改为如下所示时:

   location ^~ /help {
           alias /var/www/helpsystem;
           try_files $uri $uri/ /=404;
   }

   location ~ \.php$ {
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }

I get the following error:我收到以下错误:

2020/03/24 19:37:06 [error] 9241#9241: *1 rewrite or internal redirection cycle while internally redirecting to "/=404", client: 198.1.2.1, server: mainapplication.com, request: "GET /help.php HTTP/1.1", host: "mainapplication.com", referrer: " https://mainapplication.com/widget_settings.php " 2020/03/24 19:37:06 [错误] 9241#9241:*1 重写或内部重定向循环,同时内部重定向到“/=404”,客户端:198.1.2.1,服务器:mainapplication.com,请求:“GET /help.php HTTP/1.1", 主机: "mainapplication.com", 引用: " https://mainapplication.com/widget_settings.php "

Expand the wiki section:展开维基部分:

location ^~ /wiki {
        alias /var/www/helpsystem;
        try_files $uri $uri/ /=404;

   location ~ \.php$ {
           fastcgi_pass 127.0.0.1:9000;                  
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
}
   location ^~ /help {
           alias /var/www/helpsystem;
           try_files $uri $uri/ /=404;
      location ~ \.php$ {
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM