【问题标题】:Mojolicious for a school project: shall I install Nginx, Apache or Lighttpd?Mojolicious 适合学校项目:我应该安装 Nginx、Apache 还是 Lighttpd?
【发布时间】:2014-11-19 00:20:27
【问题描述】:

对于学校项目,我可以选择任何我喜欢的框架来创建一个相当简单的网站。我选择 Mojolicious 是因为我喜欢 Perl。

我还被要求在三个网络服务器中进行选择:Nginx、Apache 或 Lighttpd。我过去曾在 PHP 学校项目中使用过 Apache。

我完全迷失了 Mojolicious。我理解它的方式我完全不能使用任何这些网络服务器,因为我有 Morbo / Hypnotoad?无论如何,我仍然必须使用网络服务器,因为它是规则之一,那么考虑到 Mojolicious,哪一个更易于配置和最有效?

感谢您的帮助,

【问题讨论】:

    标签: apache perl nginx lighttpd mojolicious


    【解决方案1】:

    我正在使用 apache 作为 hypnotoad 的代理。工作正常,因为这样我可以使用 hypnotoad 来热部署更改。

    我在apachessites-available中的配置是:

    <VirtualHost *:8080>
        ServerAdmin webmaster@example.com
        ServerName myhost.example.com
        <Proxy *>
           Order allow,deny
           Allow from all
        </Proxy>
        ProxyRequests Off
        ProxyPreserveHost On
        ProxyPass / http://localhost:3233/ keepalive=On
        ProxyPassReverse / http://localhost:3233/ 
        RequestHeader set X-Forwarded-Proto "http"
        ErrorLog /var/log/apache2/error.log
        # debug, info, notice, warn, error, crit, alert, emerg
        LogLevel warn 
        CustomLog /var/log/apache2/access.log combined
    </VirtualHost>
    

    此链接可能对您也有帮助:

    https://github.com/kraih/mojo/wiki/Apache-deployment

    【讨论】:

      【解决方案2】:

      更新:

      我重新阅读了您的问题,并在大约 10 分钟内使用 mojolicous::lite 构建了一个快速的 lighttpd。 遵循了几个快速指南。

      如果你构建一个简单的 mojolicious::lite 比如:

      l_myapp.pl

      #!/usr/bin/env perl
      use Mojolicious::Lite;
      
      # Documentation browser under "/perldoc"
      plugin 'PODRenderer';
      
      get '/' => sub {
        my $c = shift;
        $c->render('index');
      };
      app->start;
      
      __DATA__
      
      @@ index.html.ep
      % layout 'default';
      % title 'Welcome';
      Welcome to the Mojolicious real-time web framework!
      
      @@ layouts/default.html.ep
      <!DOCTYPE html>
      <html>
        <head><title><%= title %></title></head>
        <body><%= content %></body>
      </html>
      

      然后构建一个指向您的 lite 应用程序的 conf 文件。

      lightthpd.conf

      #test
      # 
      
      server.modules = (
        "mod_fastcgi",
        "mod_cgi", 
      )
      
      server.document-root = "/var/www/html/" 
      server.port = 8080 
      
      mimetype.assign = (
        ".html" => "text/html", 
        ".txt" => "text/plain",
        ".jpg" => "image/jpeg",
        ".png" => "image/png" 
      )
      
      #------------------------
      #for host sub in IP address
      #"port" does not seem to work so use server.port
      
      $HTTP["host"] == "xxx.xxx.xxx.xxx" {
              fastcgi.server = ("/" => (( 
                  "bin-path" => "/opt/web-interface/l_myapp/l_myapp.pl fastcgi",   
                  "check-local" => "disable",
                  "fix-root-scriptname" => "enable",
                  "port" => 3000))
              )
          }
      

      在命令行: lighttpd -D -f lighttpd.conf

      这应该在通过网页“ip地址”尝试后在命令行上给你:8080

      • 2014-09-26 10:58:20: (log.c.166) 服务器启动
      • [Fri Sep 26 10:58:30 2014] [debug] 您的密码需要更改!!!
      • [2014 年 9 月 26 日星期五 10:58:30] [调试] GET "/"。
      • [Fri Sep 26 10:58:30 2014] [debug] 路由到回调。
      • [Fri Sep 26 10:58:30 2014] [debug] 从 DATA 部分渲染模板“index.html.ep”。
      • [Fri Sep 26 10:58:30 2014] [debug] 从 DATA 部分渲染模板“layouts/default.html.ep”。
      • [Fri Sep 26 10:58:30 2014] [debug] 200 OK (0.004694s, 213.038/s)。

      希望这会有所帮助。

      【讨论】:

      • 谢谢,但我想你错过了那部分:“我仍然必须使用网络服务器,因为这是规则之一 [...]”
      【解决方案3】:

      与上述类似,但您可以在 nginx 反向代理后面运行 hypnotoad:

      http://nginx.com/resources/admin-guide/reverse-proxy/

      【讨论】:

        猜你喜欢
        • 2019-02-08
        • 2017-11-26
        • 2012-03-06
        • 1970-01-01
        • 2016-11-01
        • 2015-03-28
        • 2010-11-29
        • 2011-05-31
        • 1970-01-01
        相关资源
        最近更新 更多