开发者

Running Rails and PHP on Lighttpd on 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 o开发者_如何学JAVAne server/domain.

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

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


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...


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜