是否可以在我的工作站上运行多个sinatra应用程序进行开发?
OSX El Capitan,nginx,Passenger,Sinatra
我安装了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独立,hq.local服务很好,但我必须从该顶级项目提供motherlode_ruby。有没有办法可以单独提供,以及其他本地虚拟主机?在hq.local中的Sinatra文件:
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 :(得分:0)
确保使用&#34; passenger-config --root&#34;的结果正确设置了passenger_root。然后一切都会被自动感知。