Hosting multiple sites with a single instance?

View: New views
6 Messages — Rating Filter:   Alert me  

Hosting multiple sites with a single instance?

by Max-94 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello,
     Is there any way to run different TurboGears applications on the
same port of a server? You know how Apache allows different users to
separate their websites using 'http://server/~username' format. That
way a single instance of Apache is running on port 80 but can serve
completely separated websites on the same server.
Is there any way to achieve this using TurboGears?
I suppose the logical thing would be to run different applications on
different ports but I only have port 80 available that is open for
access and I need to host completely different TurboGears applications
on the same server.
Any help would be appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Hosting multiple sites with a single instance?

by Jorge Godoy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 02 July 2008 01:50:02 Max wrote:

> Hello,
>      Is there any way to run different TurboGears applications on the
> same port of a server? You know how Apache allows different users to
> separate their websites using 'http://server/~username' format. That
> way a single instance of Apache is running on port 80 but can serve
> completely separated websites on the same server.
> Is there any way to achieve this using TurboGears?
> I suppose the logical thing would be to run different applications on
> different ports but I only have port 80 available that is open for
> access and I need to host completely different TurboGears applications
> on the same server.
> Any help would be appreciated.
It is possible.

But you'll have to think different.

This that you only have ONE application, i.e., only one RootController and
that one will import, e.g., two or three other modules that are your complete
applications.

I do that here with one big application and modules for that application (e.g.
an ERP is the application, modules for HR, Finance, Planning, etc. are the
modules I would import at the ERP application).

They can have interdependence and share your master.kid / master.html / master
template or they can be completely independent.  It is all up to how you
design it.

So, it is definitely doable and it works. :-)

But you might consider running Apache / nginx / lighttpd / whatever at port 80
and dispatching to several apps using TG that are accessible only to / from
localhost.

--
Jorge Godoy      <jgodoy@...>




signature.asc (204 bytes) Download Attachment

Re: Hosting multiple sites with a single instance?

by Max-94 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> This that you only have ONE application, i.e., only one RootController and
> that one will import, e.g., two or three other modules that are your complete
> applications.
>
> They can have interdependence and share your master.kid / master.html / master
> template or they can be completely independent.  It is all up to how you
> design it.

I agree this is a viable solution but will each separate module have
its own database or will there be just one database for all the sub-
applications in the ONE TurboGears application?

> But you might consider running Apache / nginx / lighttpd / whatever at port 80
> and dispatching to several apps using TG that are accessible only to / from
> localhost.

I have been looking into using Apache with TurboGears so each user can
run their own TG application using the http://server/~userdir
directive. Are there any tutorials that you can point me to that might
be helpful?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Hosting multiple sites with a single instance?

by Jorge Godoy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 03 July 2008 03:09:45 Max wrote:
>
> I agree this is a viable solution but will each separate module have
> its own database or will there be just one database for all the sub-
> applications in the ONE TurboGears application?

It all depends on how you code it.  You can pass to SA and SO some metadata
information about the connection.  Both allow you to specify something at your
own model.

If you need two, you'll have to code for two databases.  If you can share, you
can code to one.  Your model can be split and have some part of it inside each
module.

> I have been looking into using Apache with TurboGears so each user can
> run their own TG application using the http://server/~userdir
> directive. Are there any tutorials that you can point me to that might
> be helpful?

Not related to TG.  Check the Apache website.  Their docs are really good.  I
am not a tutorial user since I prefer going straight to the docs.  At least
not when I am trying to create something that has many constraints and is not
a standard deploy (even when it is, I try docs first and from tutorial I go
back to them to check if there isn't any security issue or mistake on the
instructions found on the web).

--
Jorge Godoy      <jgodoy@...>




signature.asc (204 bytes) Download Attachment

Re: Hosting multiple sites with a single instance?

by Max-94 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Here is the solution to this problem:

Basically we use Apache at port 80 as a proxy and redirect links to
different TurboGears applications that are running at different ports.

1 - Configure Apache to act as a proxy
       a - Install mod_proxy with the following two commands:
            sudo apt-get install apache2-mpm-prefork
            sudo a2enmod proxy_http

       b - Edit /etc/apache2/sites-enabled/000-default to include
proxy information:
            In this file, before the </VirtualHost> line, type
                <Proxy *>
                    Allow from all
                </Proxy>
                ProxyPass /mypath/ http://localhost:8000/
                ProxyPassReverse /mypath/ http://localhost:8000/

                ProxyPass /secondapp/ http://localhost:8001/
                ProxyPassReverse /secondapp/ http://localhost:8001/

            This will forward all requests at http://server.com/mypath/
to the TurboGears application running at port 8000 and vice versa.
            In the second example, the URL mapping is: http://server.com/secondapp/
<-->  TurboGears application running at port 8001

2 - Configure your TurboGears
       a - Edit 'dev.cfg' found in your TG application folder and
include the following two lines:
                server.webpath = "/mypath"
                server.socket_port=8000

            where "/mypath" is the URL offset that you wish to use and
8000 is the port you would like your TG application to run on.

3 - Restart Apache and your TurboGears application
       sudo /etc/init.d/apache2 stop
       sudo /etc/init.d/apache2 start

Now if you type http://server.com/mypath/ in your browser, it should
go to your TurboGears application's index page.

Notes:
In your TurboGears controllers or templates, make sure to wrap all
links with turbogears.url("/relativeLink") function so the webpath can
be appended to the front of the URL. So turbogears.url("/test") should
come out as "/mypath/test".
To direct to the root path, use turbogears.url("./") instead of "/"

Ideally, you should be able to access your TurboGears application from
the browser using http://server.com:8000. This solution is only meant
for those who only have a limited number of open ports to use for web
access.

Hope this helps.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Hosting multiple sites with a single instance?

by Lukasz Szybalski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tue, Jul 1, 2008 at 11:50 PM, Max <mx9.8080@...> wrote:

>
> Hello,
>     Is there any way to run different TurboGears applications on the
> same port of a server? You know how Apache allows different users to
> separate their websites using 'http://server/~username' format. That
> way a single instance of Apache is running on port 80 but can serve
> completely separated websites on the same server.
> Is there any way to achieve this using TurboGears?
> I suppose the logical thing would be to run different applications on
> different ports but I only have port 80 available that is open for
> access and I need to host completely different TurboGears applications
> on the same server.
> Any help would be appreciated.


Use mod_Wsgi. You add alias directive in apache. You can add virtual
hosts, domains, etc...

WSGIScriptAlias /yourapp1 /usr/local/turbogears/youapp1/apache/youapp1.wsgi
WSGIScriptAlias /yourapp2 /usr/local/turbogears/youapp2/apache/youapp2.wsgi
WSGIScriptAlias /yourapp3 /usr/local/turbogears/youapp3/apache/youapp3.wsgi

http://lucasmanual.com/mywiki/TurboGears#head-36b7eef1526da4fe58c73738c925f34f6bc93c1d

Lucas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price