Lately I decided to do something different than I was usually inclined to. I was using unicorn as my web application server in my development environment so I wanted to use Phusion passenger. I was looking forward to use passenger in my production environment, so I thought how about I learn it now to install and run it in my development environment ? It took some time for me to wrap my head around it but eventually I figured it out.
I already had my nginx installed but I had to remove it because I screwed some config files while figuring out passenger. Any way, the beginning is always the hard part.
I am assuming that you have no nginx installed. Run this command, it will walk you through a very easy process of installing the server with passenger.
After everything is done, navigate to localhost in your browser. It should be working.rvmsudo passenger-install-nginx-module
If you have ruby installed via rvm then no problemo. In your terminal run
Open up your /opt/nginx/conf/nginx.conf file and add the value of command from the terminal output to passenger_ruby
passenger_ruby /home/sushant/.rvm/gems/ruby-2.2.3/wrappers/ruby;
The work is still not done yet. You still have to put the right value for passenger_root. Just type
passenger-config --root
and it will output the location to the passenger. Copy that and paste it in your nginx.conf file like sopassenger_root /home/sushant/.rvm/gems/ruby-2.2.3/gems/passenger-5.0.20;
Now browser localhost and you will see the default nginx page.Lets add a vhost in case if that is what you are looking for.
server {
passenger_ruby /home/sushant/.rvm/gems/ruby-2.2.3/wrappers/ruby;
rails_env development; # add this if you get error like “Incomplete response received from application” from nginx / passenger
listen 80;
server_name sushant.com *.sushant.com;
root /usr/share/nginx/html/fuitter/public;
# You must explicitly set 'passenger_enabled on', otherwise
# Passenger won't serve this app.
passenger_enabled on;
}
Ok now to make your changes take effect, you have to restart your server. I had to download an init script because it could not find nginx command. So if you had the same problem, again, I got you covered.
git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx
No comments:
Post a Comment