I'm using Passenger as the application server for rails applications in nginx.Is it possible to run multiple rails applications using a single Passenger instance ?
Thank You
Yes you can definitely run multiple applications on Phusion Passenger. Remember that according to the Phusion Passenger documentation you're supposed to setup a virtual host with a certain domain name, and then pointing that virtual host's document root the application's "public" directory? Well... if you want to deploy more applications, you do the exact same thing. You add more virtual hosts, and in the other virtual hosts you point to other applications' "public" directories.
Related
I'm trying to deploy host a production instance for my rails 4 applications. I can currently (and successfully) host them using nginx, unicorn, and capistrano.
To save money I would like to host both of my rails 4 apps on the same instance. Is it possible to host multiple production environments, which would ideally be connected to different domains?
Thanks!
You can run multiple rails applications by configuring each application to use a different unicorn socket.
You can then configure nginx sites (see /etc/nginx/sites-enabled/www.blah.com) to route to different unicorn sockets.
Have a look at these answers:
multiple rails apps on nginx and unicorn
You need two separate virtual servers on nginx.
You can find more informations here:
http://nginx.org/en/docs/http/request_processing.html
I'm able to run rails s through ssh successfully and see the app start up just as it does on my own machine but I'm unable to access the app from the web. The app is directly under the home folder and I have a symbolic link pointing from public_html to the public folder of my rails app, just as this tutorial explains. I even tried setting up a subdomain and every other step in the tutorial to no avail. Any help would be highly appreciated.
You need an application server like Phusion Passenger, Unicorn or puma to run a Ruby app in a production environment. Typically, you'll integrate the application server into a web server's (Apache, nginx) environment.
I don't know about your hoster, but if you have root access, then you can probably use any of these application servers.
The built-in server you start by running rails server is only meant for testing purposes on your local machine. It has not been made with security, performance, stability or any other production-environment criteria in mind.
What should be the permission on rails app directory on apache server???
What is your deployment design?
Normally you'd use mongrels and apache as a load balancer for them.
So you'd run the mongrels as a user for your site, and all the rails directory should have permissions for that user.
You probably have a 'www' or 'apache' user that owns your static content and apache root document directory.
It's common convention to make this user own your rails app as well to preserve the same permissions.
If you use something like capistrano, I think it has builtin recipes for permission structure on top of your release directory after deploying.
As Angelus said, it depends on your server setup and deployment design. You can use mongrels (or thins, or unicorns, or...) with Apache as a reverse-proxy, but your question leads me to believe you're using Phusion Passenger (aka mod_rails).
If that's the case, the mod_rails site has several very helpful screencasts which you should watch. Generally, though, mod_rails will run as whichever user owns your app's environment.rb file. See the Passenger user switching docs for details on your permission setup.
While installing apache it creates www-data group and owner so you have to give the ownership of this user for your application.
Then restart the apache service.
rails application works fine.
Is there any way to configure Capistrano for deploying many webs on a server?
I would like to have a project on port 80 an other project on port 1000 and manage each one with different dbs.
As Leonm said, the port numbers are completely irrelevant - you configure your application and web server environment with multiple virtual hosts, and simply deploy to the vhost webroot directory.
For Apache, you can get some help here.
http://httpd.apache.org/docs/1.3/vhosts/
I am hosting my own VPS (multiple) with Apache2 + Passenger (mod_rails) + vhost config.
Share some more specific details if you wish to.
My capistrano script looks something like this (I trimmed some stuff for IP safety)
http://pastie.textmate.org/699537
then I have vhosts configured for each of these folders where app gets deployed.
apache makes it a breeze.
We have a RedHat box with Apache2, PHP5 and MySQL 5 for much of our development. Now, we have a Rails client, and we need to set up a Rails app on the same server. Can we install Ruby and the Rails framework with the same Apache, or should we avoid this? Why or Why not? Is it possible to direct subdomains to either PHP or Ruby in the individual V-host definitions?
Yes, you can configure your virtual hosts to Rails, PHP, or anything else with the proper configuration. The details depend largely on how you are connecting to Rails, but generally however you would configure a single purpose Apache server should work for the virtual hosts.
Yeah - Install passenger, then you can configure your sites through your apache conf files. The passenger docs contain everything you'll need to know!