# Multiple projects - Apache

**URL:** <https://www.ruby-forum.com/t/multiple-projects-apache/173594>\
**Category:** Ruby\
**Created:** [August 11, 2009, 8:32pm UTC](https://www.ruby-forum.com/t/multiple-projects-apache/173594 "2009-08-11T20:32:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [August 11, 2009, 8:32pm UTC](https://www.ruby-forum.com/t/multiple-projects-apache/173594/1 "2009-08-11T20:32:52Z")

</div>

Hi,  
I’m trying to configure Apache so I can create multiple rails projects  
without modifying httpd.conf everytime. Right now, I have one project  
setup and a apache virtualhost that points to it. Here is how I have it  
configured.

\<VirtualHost \*:80\>  
ServerName [rails.example.com](http://rails.example.com)  
DocumentRoot /var/www/rails\_project/public  
RailsEnv development

I would like to be able to set my documentRoot to /var/www and access my  
projects by appending the project directory name to the url (e.g.  
[rails.example.com/rails\_project](http://rails.example.com/rails_project)).

For instance, when I set it up like that it I can access a project that  
is located in /var/www/rails\_project, by going to  
[rails.example.com/rails\_project/public](http://rails.example.com/rails_project/public).

But I have routing problems after that. Here is what I get when clicking  
on “About your applications environment”

Not Found  
The requested URL /rails\_project/public/rails/info/properties was not  
found on this server.

I’m stuck here, so any help is really appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [August 12, 2009, 2:28pm UTC](https://www.ruby-forum.com/t/multiple-projects-apache/173594/2 "2009-08-12T14:28:45Z")

</div>

Excerpts from Joe’s message of Tue Aug 11 14:31:53 -0400 2009:

> Hi,  
> I’m trying to configure Apache so I can create multiple rails projects without  
> modifying httpd.conf everytime. Right now, I have one project setup and a  
> apache virtualhost that points to it. Here is how I have it configured.
> 
> \<VirtualHost \*:80\>  
> ServerName [rails.example.com](http://rails.example.com)  
> DocumentRoot /var/www/rails\_project/public  
> RailsEnv development

Hi Joe,

AFAIK, that’s not possible with passenger. I believe that a new vhost is  
needed for every rails application on your machine (someone please  
correct me if I’m wrong).

If you have an existing vhost with something else on it, you can specify  
that your rails application is in a subdirectory of that document root  
like this:

\<VirtualHost \*:80\>  
ServerName [rails.example.com](http://rails.example.com)  
DocumentRoot /var/www/rails\_project/public  
RailsEnv development  
RailsBaseURI /rails

Regards,  
Jason

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [August 12, 2009, 3:06pm UTC](https://www.ruby-forum.com/t/multiple-projects-apache/173594/3 "2009-08-12T15:06:14Z")

</div>

Hi friends.

The way I’m doing this is to have a single directory I symlink all of my  
app’s ‘public’ directory to. I set this as my DocumentRoot and then have  
a  
single VHOST file for all of my apps. It isn’t pretty, but it’s fairly  
easy  
to parse with Ruby. So, my VHOST file looks something like this:

\<VirtualHost \*:80\>  
DocumentRoot /u/apps  
RailsBaseUri /foo  
RailsBaseUri /bar

# etc…

I have had _zero_ luck using multiple VHOST files. This may be due to my  
own  
lack of knowledge in using Apache though.

You may wish to redirect your query to the Passenger mailing list  
though.  
They’ll likely be of more help. Keep me posted though. I’d love to hear  
what  
your resolution is.

James H.

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [August 12, 2009, 6:17pm UTC](https://www.ruby-forum.com/t/multiple-projects-apache/173594/4 "2009-08-12T18:17:40Z")

</div>

On Aug 12, 2009, at 4:04 PM, James H. wrote:

> I have had _zero_ luck using multiple VHOST files. This may be due  
> to my own  
> lack of knowledge in using Apache though.

There’s a free preference pane for OS X that’s floating around  
somewhere that essentially does this:

 NameVirtualHost \*:80 ServerName \_default\_ Include /path/to/passenger\_vhosts/\*.conf

The is optional - just protects against idiots like me -  
and then a sample foo.conf would look like …

\<VirtualHost \*:80\>  
ServerName foo.local  
DocumentRoot “/u/rail\_sites/foo/public”  
RailsEnv development  
\<directory “/u/rail\_sites/foo/public”\>  
Order allow,deny  
Allow from all

Adding a vhost just needs an apache reload.

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [August 12, 2009, 7:46pm UTC](https://www.ruby-forum.com/t/multiple-projects-apache/173594/5 "2009-08-12T19:46:04Z")

</div>

Thanks for the reply. I ended up doing pretty much the same thing. I  
create the project, link to the public folder and then in an .htaccess  
file, I add RailsBaseURI /railsProject.

The only problem I have, is that it requires a trailing slash after the  
project name when accessing it via the web.

----- Original Message ----  
From: James H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Wednesday, August 12, 2009 8:04:46 AM  
Subject: Re: multiple projects - Apache

Hi friends.

The way I’m doing this is to have a single directory I symlink all of my  
app’s ‘public’ directory to. I set this as my DocumentRoot and then have  
a  
single VHOST file for all of my apps. It isn’t pretty, but it’s fairly  
easy  
to parse with Ruby. So, my VHOST file looks something like this:

\<VirtualHost \*:80\>  
DocumentRoot /u/apps  
RailsBaseUri /foo  
RailsBaseUri /bar

# etc…

I have had _zero_ luck using multiple VHOST files. This may be due to my  
own  
lack of knowledge in using Apache though.

You may wish to redirect your query to the Passenger mailing list  
though.  
They’ll likely be of more help. Keep me posted though. I’d love to hear  
what  
your resolution is.

James H.
