【问题标题】:Nginx vs Apache or using Apache with nginx [closed]Nginx vs Apache 或者使用 Apache 和 nginx [关闭]
【发布时间】:2011-10-26 03:30:24
【问题描述】:

我已经运行了一个服务器 javascript 小部件的网站大约 2 年。现在我的问题是我应该纯粹使用 nginx 还是应该继续使用 apache 和 nginx。

我每天大约有 200 次注册,这意味着有时小部件的请求率每天会上升 2000 次。所以,现在的问题是切换到 nginx 意味着我将无法使用我在 apache 中使用的重写规则。

现在这是我知道的一个问题,但是我在 nginx 环境中会看到我在 Apache 中没有的其他问题吗?

你会建议我完全切换到 nginx 还是继续使用 apache 和 nginx 作为反向代理?

【问题讨论】:

    标签: apache nginx


    【解决方案1】:

    您仍然可以使用 Apache 的重写规则,稍作修改(我从Nginx Primer 获取):

    阿帕奇:

    RewriteCond   %{HTTP_HOST}   ^example.org$   [NC]
    RewriteRule   ^(.*)$   http://www.example.com/$1   [R=301,L]
    

    Nginx:

    if ($host != 'example.org' ) {
        rewrite  ^/(.*)$  http://www.example.org/$1 permanent;
    }
    

    另一个问题是 .htaccess 文件,但这只有在您与他人共享服务器时才会成为问题。

    我还将研究您所依赖的任何 Apache 模块,并确保 Nginx 等效模块包含相同的功能。一定要先在测试环境中使用 Nginx 测试您的 webapp,以确定任何问题。

    最后,如果您的目标是更好的性能,那么从 Apache 迁移到 Nginx 应该是值得的。

    【讨论】:

    • +1 好,这正是我所需要的,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-31
    • 2014-11-21
    • 2012-09-21
    • 2011-04-07
    • 2012-12-15
    • 2012-10-29
    • 2012-02-27
    相关资源
    最近更新 更多