running multiple rails websites using phusion passenger 3.0.17 with nginx
I searched google for deploying multiple rails websites using phusion passenger 3.0.17 with nginx but I didn't get relevant results. Any how I completed passenger nginx setup by running passenger-install-nginx-module command.
Ques 1) I am looking for proper beginner tutorial for running multiple rails websites using phusion passenger 3.0.17 with nginx
Ques 2) I am looking commands for start, stop, restart the (whole passenger nginx server (ie) for all websites) and also for (Individual rails websites)
Note: I am not looking for passenger standalone solution. I am using REE 1.8.7 and rails 2.3.14
According to the documentation for Passenger, you create a new vhost for each app you want to deploy. And point the site root
at your apps public directory, and add the passenger_enabled
directive. Exactly the same as deploying with Apache.
http {
...
server {
listen 80;
server_name www.mycook.com;
root /webapps/mycook/public;
passenger_enabled on;
}
...
}
More here: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_a_ror_app
In regards question 2. Restarting depends on what you are trying to do. I'm going to assume you're using a distro that uses init.d
These are 3 cases where you do a different kind of 'restart'.
You have an issue with some config you have on Nginx. Or it's behaving strangely. So you would restart the Nginx service like this: /etc/init.d/nginx restart
The next case is you have a rails or sinatra app deployed on Nginx with the passenger module. And you want to make it reload some changes you just pushed to the server. Passenger watches the tmp/restart.txt
file in your application. So by simply runnging touch tmp/restart.txt
. While cd'd into the app's folder will tell Passenger to reload the application.
And the last case for restarting/reloading is reload for Nginx. You use this when you add or change your VHOSTs. /etc/init.d/nginx reload
. This allows you to reload your vhosts and other config without dropping connections.
Have a gander at the Passenger Documentation, it is very thorough. nginx-passenger docs
Here is a step-by-step tutorial on Configuring Nginx for multiple virtual hosts: http://articles.slicehost.com/2007/12/7/ubuntu-gutsy-installing-nginx-via-aptitude
Note that:
$ touch current/tmp/restart.txt
in the server app directory after pushing files, if you want to apply a production fix directly. <NGINX_HOME>/bin/nginx stop
to stop and then <NGINX_HOME/bin/nginx
to start. To help you, here are my configuration files.
nginx.conf:
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /rails/common/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/passenger-3.0.17;
passenger_ruby /rails/common/ruby-1.9.2-p290/bin/ruby_with_env;
passenger_max_pool_size 30;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
include /rails/common/nginx/conf/sites-enabled/*.conf;
}
A sample site.conf inside sites-enabled folder:
server {
listen 80;
server_name domainname1.com;
root /rails/myapp1/current/public;
passenger_enabled on;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /system/maintenance.html break;
}
}
A new file in sites-enabled is all it takes to add a new site.
链接地址: http://www.djcxy.com/p/32452.html上一篇: 生产服务器中的apache下的多个红宝石