【问题标题】:nginx and catalyst configurationnginx和催化剂配置
【发布时间】:2012-12-03 15:09:04
【问题描述】:

我在使用 nginx 部署 Catalyst 应用程序时遇到问题,并且 快速cgi。我试图在 ubuntu 12.04 下执行此操作。

我已成功配置 nginx 以提供来自我的静态内容 应用程序的 /root 子目录。然而,当我尝试任何我的动态 urls,我在应用程序的错误日志中收到 404 错误,说 (unmapped) url is not found,这让我相信 nginx 是 尝试提供类似于静态页面的请求,而不是 将其发送到我的 Catalyst 应用程序。

要重申,点击“localhost:3001/root/static.html”会导致 静态内容在浏览器中成功显示,但是 点击 'localhost:30001/expense/editor' 会导致以下错误:

"GET /expense/editor HTTP/1.1" 404

(其中 '/expense/editor' 是我的应用程序中的一条路径,我可以 运行内置 Catalyst 开发时成功访问 服务器)。

我正在启动 Catalyst 应用程序:

> perl script/budgetweb_fastcgi.pl -l localhost:3003

我也尝试过运行 /etc/init.d/fcgiwarp。我不清楚是否需要运行 单独的 fastcgi 包装器,或者如果上面的 perl 脚本 我的 fastcgi 包装。我编辑了 fcgiwrap 以使用 TCP 套接字 (127.0.0.1:3003),它 然后阻止我同时运行 /etc/init.d/fcgiwrap 和 script/budgetweb_fastcgi.pl 同时使用,因为它们都使用 同一个插座。所以我猜我应该只使用催化剂 脚本?此外,在运行 fcgiwrap 时,我收到 502“bad gateway”错误 尝试访问静态内容时。

任何帮助或帮助指针,将不胜感激。到目前为止,我已经查看了以下页面(其中包括;StackOverflow 只允许我发布两个链接):

Catalyst wiki
HOWTO: Deploy a Catalyst application using FastCGI and nginx

这是我的服务器 nginx 配置文件:

server {
       listen       3001;
       server_name  budgetweb.com;
       root     /local/www/money/budgetweb;

       location /root {
           add_header Cache-control public;
       root /local/www/money/budgetweb/;
       }

       location / {
          access_log    /local/www/money/budgetweb/logs/access.log;
          error_log /local/www/money/budgetweb/logs/error.log;
          index  index.html index.htm index.pl;
      try_files $uri =404;
      gzip off;

      fastcgi_pass  localhost:3003;
          fastcgi_index index.pl;

          include /etc/nginx/fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME  /local/www/money/budgetweb$fastcgi_script_name;
      fastcgi_param  SCRIPT_NAME /;
      fastcgi_param  PATH_INFO $fastcgi_script_name;
        } 

       # Disable gzip (it makes scripts feel slower since they have to complete
       # before getting gzipped)
       gzip off;

#       include         /etc/nginx/fcgiwrap.conf;
}

【问题讨论】:

    标签: perl nginx fastcgi catalyst


    【解决方案1】:

    Catalyst 中包含的 fastcgi.pl 脚本是您的 FastCGI 包装器。您所要做的就是在套接字上启动它,然后将您的网络服务器指向该套接字,一切都应该通过。对于生产系统,您唯一需要做的就是创建一个启动/停止脚本,该脚本将在启动和关闭时启动和停止您的应用程序。 start 命令看起来很像你上面运行的(你可能想添加一个 '-d' 标志来守护它。)

    在您的网络服务器配置中,将“/”配置为指向您的应用程序应该没问题。您可以尝试删除“index”、“try_files”和“fastcgi_index”配置行,这可能会导致 nginx 尝试静态提供内容,而不是将请求传递给您的应用程序。

    【讨论】:

      猜你喜欢
      • 2013-04-10
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2011-03-28
      • 2016-09-08
      • 2020-01-05
      • 2020-12-14
      • 1970-01-01
      相关资源
      最近更新 更多