2

好的,这是我的第一个 vps,这是我的 hello world 测试。我离展示我的 Rails 应用程序只有一步之遥

我有一个运行 Ubuntu 的 VPS。

我有一个 Rails 项目就坐在这里:

(我使用 git 从 git hub 拉出来,然后运行 ​​'bundle install' 在 vps 上安装 gem,根本没有使用 Capistrano)

/home/starkers/rails_application ->

测试应用

当我在浏览器中访问我的 vps 的 ip 时,我会收到该Welcome to nginx!页面。

最后,

sudo nano /opt/nginx/conf/nginx.conf

打开我的配置文件。

现在,我在大约一个小时内没有在这方面取得任何进展。所有在线指南都显示了稍微不同的 nginx.conf 结构,所以我在这里有点摸不着头脑。

nginx.conf 文件非常大,我需要更改哪些变量才能向服务器路由直接发送 http 请求到 rails 项目?

我认为这对我的目的很重要:

  server {
    listen       80;
    server_name  localhost;

        #charset koi8-r;
 #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
   }

如果有人可以向我解释一下,我将不胜感激。我打赌这里引用的 index.html 是“欢迎使用 nginx!” 页。公共网络服务器是否应该始终侦听端口 80?server_name 重要吗?

然后如何调整 nginx.conf 文件,以便我购买的 url 将路由项目?

真的不介意在这里提供一些帮助。

4

1 回答 1

0

这确实是一个多步骤的过程。您将需要:

  1. 为要从中托管应用程序的域配置 nginx 服务器块。
  2. 在 Rails 应用程序和 nginx 之间配置应用程序服务器或其他“桥梁”。我会推荐乘客宝石。

如果你决定走乘客路线,你可以修改上面的 server 块,如下所示:

passenger_root /somewhere/passenger-x.x.x;
passenger_ruby /usr/bin/ruby;
passenger_max_pool_size 10;
server {
    # uncomment the line below if you will be serving multiple domains/websites from this box
    # server_name example.com www.example.com;
    listen 80;

    # point this to the path to your rails app's public directory
    root /home/starkers/rails_application/test_app/public;

    passenger_enabled on;
}

来源:http ://www.modrails.com/documentation/Users%20guide%20Nginx.html

您可能会对这个来自 digitalocean 的如何安装指南感兴趣

于 2013-11-08T02:06:35.973 回答