# Multiple sites with mongrel and nginx

**URL:** <https://www.ruby-forum.com/t/multiple-sites-with-mongrel-and-nginx/113797>\
**Category:** Deployment\
**Created:** [September 5, 2007, 2:28am UTC](https://www.ruby-forum.com/t/multiple-sites-with-mongrel-and-nginx/113797 "2007-09-05T02:28:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 5, 2007, 2:28am UTC](https://www.ruby-forum.com/t/multiple-sites-with-mongrel-and-nginx/113797/1 "2007-09-05T02:28:34Z")

</div>

I’ve got a standard nginx config ([NameBright - Coming Soon](http://www.urbanpuddle.com/nginx.conf))  
which I use to server one php app and one rails app. My  
mongrel\_cluster.yml file resides in /etc/mongrel\_cluster and is a  
symlink to my\_app1’s config/mongrel\_cluster.yml file. That file looks  
like this:

* * *

cwd: /var/www/my\_app1  
port: 8000  
environment: production  
group: www-data  
user: www-data  
address: 127.0.0.1  
pid\_file: log/mongrel.pid  
servers: 3

All is great and works fine, but I’m wondering how to extend this to be  
able to run multiple rails apps at the same time? Do I have to modify  
my nginx.conf like so?

#for my\_app1  
upstream mongrel {  
server 127.0.0.1:8000;  
server 127.0.0.1:8001;  
server 127.0.0.1:8002;  
}

#for my\_app2  
upstream mongrel {  
server 127.0.0.1:8100;  
server 127.0.0.1:8101;  
server 127.0.0.1:8102;  
}

And if I do, how do I modify the mongrel\_cluster file so it knows to  
launch both mongrel clusters?

Thanks in advance…

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 5, 2007, 2:47am UTC](https://www.ruby-forum.com/t/multiple-sites-with-mongrel-and-nginx/113797/2 "2007-09-05T02:47:51Z")

</div>

I guess I’ll partially answer my own question…

I made the changes to nginx.conf and started the mongrel clusters  
manually with sudo mongrel\_rails cluster::start and it works. Still, it  
would be nice to know if it’s possible to fire off 2 different mongrels  
via the /etc/init.d/mongrel\_cluster start command…

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 5, 2007, 3:45pm UTC](https://www.ruby-forum.com/t/multiple-sites-with-mongrel-and-nginx/113797/3 "2007-09-05T15:45:50Z")

</div>

/etc/init.d/mongrel\_cluster:

set CONF\_DIR to the directory containing your mongrel configurations,  
then

/etc/init.d/mongrel\_cluster restart

does a full restart of all the clusters on the box.

Jason
