在 Linux 上的 Lighttpd 上运行 Rails 和 PHP

发布于 2024-10-16 12:58:39 字数 151 浏览 8 评论 0原文

好吧,我想知道是否有一种方法可以在 Ubuntu 上的 Lighty 上运行 Rails 和 PHP。我想在一台服务器/域上运行我的 PHP 项目和 Rails 项目。

我对 Linux 的经验很少,所以请原谅我的天真。

如果有办法做到这一点,请告诉我:)

Well, I'm wondering if theres a way to run both rails and PHP on Lighty, on Ubuntu. I want to run both my PHP projects and Rails projects on the one server/domain.

I have little experience with Linux really, so forgive my naivety.

If theres a way of doing this please let me know :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一向肩并 2024-10-23 12:58:39

运行它们确实非常简单。我一直这样做(ROR 运行 Redmine,PHP 运行其余的)。

您有 2 个 ROR 实物选择。要么从 FastCGI(我所做的)提供服务,要么使用独立服务器(如 Mongrel 等)和代理运行它。两者各有优点。 FastCGI 的优点是它是独立的(无需运行辅助服务器)。独立的优点是更容易配置。

如果您有具体问题,我可以提供指导,但互联网上有关于如何执行此操作的指南。

我的 lighttpd.conf:

$HTTP["host"] =~ "my.ror.site" {
    server.error-handler-404="/dispatch.fcgi"
    fastcgi.server = (".fcgi" => ("ror_1" => (
            "min-procs"=>8,
            "max-procs" => 8,
            "socket" => "/tmp/myrorlock.fastcgi",
            "bin-path"=> "/path/to/ror/site/public/dispatch.fcgi",
            "kill-signal" => 9,
            "bin-environment" => ( "RAILS_ENV" => "production" )
    )))
}

fastcgi.server = ( ".php" =>
    (
        (
            "socket" => "/tmp/php-fastcgi.socket",
            "bin-path" => "/usr/bin/php-cgi -c /etc/php.ini",
            "min-procs" => 1,
            "disable-time" => 1,
            "max-procs" => 1,
            "idle-timeout" => 20,
            "broken-scriptfilename" => "enable",
            "bin-copy-environment"=> (
                "PATH", "SHELL", "USER"
            ),
            "bin-environment" => (
                "PHP_FCGI_CHILDREN" => "40",
                "PHP_FCGI_MAX_REQUEST" => "50000"
            )
        )
    )
)

就是这样。请注意 kill-signal 选项。这很重要,否则每次重新启动服务器时都会遇到僵尸进程......

It's really quite simple to run them both. I do it all the time (ROR to run Redmine, and PHP for the rest).

You have 2 real options for ROR. Either serve it from FastCGI (what I do), or run it with a standalone server (like Mongrel, etc) and proxy to it. Both have advantages. FastCGI has the advantage that it's self-contained (no secondary server to run). The standalone has the advantage that it's easier to configure.

If you have specific questions, I can guide, but there are guides on the internet on how to do this.

My lighttpd.conf:

$HTTP["host"] =~ "my.ror.site" {
    server.error-handler-404="/dispatch.fcgi"
    fastcgi.server = (".fcgi" => ("ror_1" => (
            "min-procs"=>8,
            "max-procs" => 8,
            "socket" => "/tmp/myrorlock.fastcgi",
            "bin-path"=> "/path/to/ror/site/public/dispatch.fcgi",
            "kill-signal" => 9,
            "bin-environment" => ( "RAILS_ENV" => "production" )
    )))
}

fastcgi.server = ( ".php" =>
    (
        (
            "socket" => "/tmp/php-fastcgi.socket",
            "bin-path" => "/usr/bin/php-cgi -c /etc/php.ini",
            "min-procs" => 1,
            "disable-time" => 1,
            "max-procs" => 1,
            "idle-timeout" => 20,
            "broken-scriptfilename" => "enable",
            "bin-copy-environment"=> (
                "PATH", "SHELL", "USER"
            ),
            "bin-environment" => (
                "PHP_FCGI_CHILDREN" => "40",
                "PHP_FCGI_MAX_REQUEST" => "50000"
            )
        )
    )
)

And that's it. Note the kill-signal option. that's important, otherwise you'll wind up with zombie processes everywhere every time you restart the server...

本王不退位尔等都是臣 2024-10-23 12:58:39

查看 Lighty 配置目录的 conf.d 子目录中的 fastcgi.conf (不确定它在 Ubuntu 上的位置,但快速搜索表明 /etc/lighttpd )。 PHP 和 Rails 都有注释掉的示例;通过将两者结合起来,您应该能够获得您正在寻找的设置(尽管我建议先让一个工作,然后再设置另一个)。

FastCGI 是 Lighty 与 Ruby 或 PHP 等运行时通信的方法。 Lighty 也可以使用 SCGI,尽管我自己从未使用过它并且不确定它的效果如何(最后我听说它仍然是实验性的)。

您还可能会发现 Lighty 文档 wiki 上的 优化 FastCGI 页面很有帮助,尽管它相当有用PHP/MySQL 特定的。

Check out fastcgi.conf in the conf.d subdirectory of Lighty's configuration directory (not sure where it's located on Ubuntu, but a quick search suggests /etc/lighttpd). There are commented-out examples for both PHP and Rails; by combining the two, you should be able to get the set-up you're looking for (though I'd suggest getting one working first and then setting up the other).

FastCGI is the method by which Lighty can communicate with runtimes like Ruby or PHP. Lighty can also use SCGI, though I've never use it myself and am not sure how well it works (last I heard it was still experimental-ish).

You may also find the Optimizing FastCGI page on Lighty's documentation wiki helpful, though it's fairly PHP/MySQL-specific.

万人眼中万个我 2024-10-23 12:58:39

我不使用莱特。考虑到 Apache 的 Passenger 插件的强大功能,Rails 最好与 Passenger 和 Apache 一起使用。我通过将 Wordpress (PHP) 的路径指向其他位置,在与 Rails 应用程序相同的域中提供服务。 这是一篇要关注的文章。 HTH。

I don't use Lighty. Rails is best served with Passenger and Apache, considering the power of Passenger add-on to Apache. I served Wordpress (PHP) in the same domain as my Rails app by pointing its path to somewhere else. Here's an article to follow. HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文