2015-10-20 50 views
1

是否有可能在我的工作站上運行多個sinatra應用程序進行開發?埃爾卡皮坦nginx乘客服務多Sinatra

OSX埃爾卡皮坦,nginx的,客運,西納特拉

我有nginx的和乘客安裝。它在獨立模式下工作。但是,我使用這種類型的軟件來爲我提供的內部「主頁」提供服務,而且我正在開發不同階段的多個項目。所以單獨使用是非常嚴格的。我想在一個子目錄中爲另一個本地「虛擬主機」應用程序提供服務。也就是說,'/'和'/ motherlode_ruby'以及其他未來的嵌套應用程序。

我覺得Passenger可以同時服務多個實例。不幸的是,Phusion沒有很好地解釋這種類型的nginx多模式設置,因爲它們專注於nginx上的獨立。因此,這裏是我的設置:

nginx.conf:

http { 
      index         index.html; 
      access_log       /usr/local/var/log/access.log; 

      passenger_root /usr/local/opt/passenger/libexec/src/ruby_supportlib/phusion_passenger/locations.ini; 
      passenger_ruby /Users/rich/.rvm/gems/ruby-2.2.3/wrappers/ruby; 

      server { 
       listen      8080 default_server; 
       server_name     hq.local; 
       include       /usr/local/etc/nginx/mime.types; 
       access_log     /usr/local/var/log/access_HQ5.log; 
       error_log     /usr/local/var/log/error_HQ5.log debug; 
       error_page 404  /404.html; 
       root       /Library/WebServer/Documents/HQ5/public;  
       passenger_enabled on; 
       passenger_base_uri /; 
       passenger_base_uri /motherlode_ruby; 
       passenger_env_var DATABASE_USERNAME myusername; 
       passenger_env_var DATABASE_PASSWORD mypassword; 

       location/{ 
        autoindex off; 
         # try_files    $uri $uri/ /index.html?$query_string; 
       } 

       location = /favicon.ico { access_log off; log_not_found off; } 
       location = /robots.txt { access_log off; log_not_found off; } 

       sendfile      off; 
      } 
      # other servers currently commented out 
    } 

實際上,這就是我在尋找:

hq.local: 
     app.rb 
     app1: 
      app.rb              
      Gemfile 
      methods.rb 
      public: 
       main.css 
      ref.rb 
      views: 
       index.erb 
       result.erb 
     app2: 
      app.rb 
      Gemfile 
      methods.rb 
      public: 
       main.css 
      ref.rb 
      views: 
       index.erb 
       result.erb 
     Gemfile 
     methods.rb 
     public: 
      main.css 
     ref.rb 
     views: 
      index.erb 
      result.erb 

目前正在獨立於0.0.0.0:3000總部。本地服務很好,但我必須從該頂級項目提供motherlode_ruby。有沒有辦法可以單獨服務,以及其他地方的虛擬主機? Sinatra文件在hq.local:

require 'sinatra/base' 

    class MyApp < Sinatra::Base 
     get "/" do 
      "OK, yer in HQ5 top" 
     end 

     get "/motherlode_ruby" do 
      "OK, yer in HQ5/motherlode_ruby" 
     end 

     get "/alpha" do 
      "OK, yer in HQ5/alpha" 
     end 

     get "/bravo" do 
      "OK, yer in HQ5/bravo" 
     end 
    end 

回答

0

確保您的passenger_root使用「passenger-config --root」的結果正確設置。然後一切都會自動感應。

相關問題