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.
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 am using Cent OS 5.8 with kloxo.
I have a ruby application. When i start the application , by default it starts at port nos 3000. So to access dat i need to put domain.com:3000 .
This doesn't look good , so I decided to run mongrel at port nos 80.
now i am able to access domain.com
But now i want that the application shall run in a sub domain and there should be a different website running in my main domain.
I tried putting code in httpd.conf and it didn't work.
Can any one help me on this.
Thank You
You can use nginx as a proxy to accomplish this. You can then run your apps on ports 3000, 3001 and 3002 (for example) and let nginx route the traffic based on the hostname requested. But I recommend you looking into Phusion Passenger for production environments because it enables you to run applications like you're used to in an Apache or nginx environment. According to Phusion, it also outperforms Mongrel, but your mileage may vary of course.
I've developed a couple of applications which I'm ready to deploy. To do so, I've configured Capistrano and I'm already able to run cap deploy, which runs properly. However, I'm totally lost as to how to continue from here. My setup is EC2 + Rails 3.2 + Ruby 1.9.3 + Passenger + Nginx (the one Passenger installs first time you try to start it) + Capistrano.
Until now, I just ran passenger start on my app root folder, which would start passenger on port 3000, and I would start the second app on port 3001. Now, what I need is to have this 2 apps under 2 different domains, say www.domain1.com and www.domain2.com.
How am I supposed to start the servers now? I can go to the respective current folders that Capistrano created and run something like passenger start -e production -p 3001 -d and it starts running as a daemon, but, shouldn't capistrano take care of this? All I see is that, on each deploy, it touches the restart.txt file and that forces a "soft restart", which is not enough (as far as I know) if you've changed gems. Shouldn't Capistrano be starting and stopping Passenger, not me?
How do I run the 2 apps on 2 domains? As far as I know, you can't point a domain to a port, and all I've managed to do now is to run 1 of the applications by running Passenger on port 80 with rvmsudo, but of course this only works for 1 application. After searching a bit I've found something about Nginx Virtual Servers. How do you do this? I mean, I have never touched anything specific to Nginx, just Passenger! Am I supposed to forget about Passenger and deal with Nginx as a service? How?
Thanks in advance!
I believe to start servers there's a specific cap command to start servers, but i don't know much about capistrano, just played with it a little bit before.
As for the second part, this is where nginx takes part, nginx will handle forwarding each domain to the specific port, using proxy_pass, take a look at this example
server {
server_name: example1.com;
proxy_pass: http://127.0.0.1:3000;
}
server {
server_name: example2.com;
proxy_pass: http://127.0.0.1:3001;
}
How do I configure an Amazon EC2 instance as a personal space to serve up whatever Ruby on Rails or WordPress projects I want, with their own domains? As a developer, I've found surprisingly little information on how to create your own "bucket" for all your various web-based projects.
It's surprisingly easy to get started but there are dozens of different ways to go about it. For the sake of giving you relevant resources I'm going to make a few assumptions about your setup and try to paint with broad strokes:
You're running a Debian-based Linux distribution (Ubuntu is popular and has a great community)
You're running a LAMP (Linux, Apache, MySQL, and PHP) stack (see Installing LAMP Server in the Ubuntu documentation).
You'll be deploying your sites to the default server location of /var/www
The first thing you'll want to do is read up on virtual hosts (vhosts). A common pattern is to put virtual hosts' web roots in subdirectories of /var/www/vhosts/ (e.g. /var/www/vhosts/example.com/), though these can technically live anywhere on the server.
After creating your document roots you'll give each site each a virtual host file in /etc/apache2/sites-available that looks (at a very high/rudimentary level) something like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/vhosts/example.com/
</VirtualHost>
This tells Apache to listen for requests for www.example.com and route them to /var/www/vhosts/example.com. There are a whole mess of Apache vhost configuration options, I'd recommend a Google search for some more specific examples though looking at the 000-default vhost that comes bundled with Apache on Ubuntu is a good place to start.
When you're ready to activate the vhost you'll need to enable the virtual host and reload/restart Apache:
$: a2ensite {your vhost file name} # Creates a symlink to this vhost file in /etc/apache2/sites-enabled/
$: service apache2 restart # restart Apache
Since you want to point different domains to your projects you'll simply need to create a DNS record (A-records will be the easiest unless you're dealing with all sorts of shifting IP addresses) and point it to the IP address of your server. Apache will route the domain to the appropriate virtual host.
For Rails projects the web root should be the public/ directory, so your DocumentRoot directive will be DocumentRoot /var/www/vhosts/example.com/public. You'll also need to be running a Ruby-compatible server for Rails apps, Phusion Passenger, Thin, and Unicorn are all pretty popular.
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.