I see how I should probably structure this for multiple sites now.  Since 
my server has only one IP, like you said I can do either of two methods, 
separate vhost for each site (prefixed domains, or combined into one (sub 
domains).  Heres the configs I came up with, I will have to test it with a 
new project to see if it works: 

                                            VHOST CONFIGURATION - MULTIPLE 
SITES                                                    
                                                
        # wsgi.load
        
LoadModule wsgi_module /usr/lib/apache2/modules/
mod_wsgi-py35.cpython-35m-x86_64-linux-gnu.so
WSGIRestrictEmbedded On
                                        
                                                
    METHOD 1:    Separate virtual host per project  -  site1  site2      
                                        
                                
                                # site1.conf

<VirtualHost *:80>
    ServerName site1.192.168.1.102
    ServerAlias    site1.me
    
    WSGIDaemonProcess site1 
python-home=/var/www/site1/FlaskApp/FlaskApp/venv

    WSGIProcessGroup site1
    WSGIApplicationGroup %{GLOBAL}
    
    WSGIScriptAlias / /var/www/site1/FlaskApp/flaskapp.wsgi

</VirtualHost>


                                # site2.conf

<VirtualHost *:80>
    ServerName site2.192.168.1.102
    ServerAlias    site2.me
    
    WSGIDaemonProcess site2 
python-home=/var/www/site2/FlaskApp/FlaskApp/venv

    WSGIProcessGroup site2
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptAlias / /var/www/site2/FlaskApp/flaskapp.wsgi

</VirtualHost>




    METHOD 2:   Combined into one virtual host , 3 sites at sub URLs    
ie:   sites.me/site4   sites.me/site5    sites.me/site6  
    
                                    # sites.conf
                                    
<VirtualHost *:80>
    ServerName sites.192.168.1.102
    ServerAlias    sites.me
    
    WSGIDaemonProcess site4 
python-home=/var/www/site4/FlaskApp/FlaskApp/venv
    WSGIDaemonProcess site5 
python-home=/var/www/site5/FlaskApp/FlaskApp/venv
    WSGIDaemonProcess site6 
python-home=/var/www/site6/FlaskApp/FlaskApp/venv

    WSGIProcessGroup sites
    WSGIApplicationGroup %{GLOBAL}
    
    WSGIScriptAlias /site4 /var/www/site4/FlaskApp/flaskapp.wsgi
    WSGIScriptAlias /site5 /var/www/site5/FlaskApp/flaskapp.wsgi
    WSGIScriptAlias /site6 /var/www/site6/FlaskApp/flaskapp.wsgi

</VirtualHost>    



> On 12 May 2016, at 6:32 PM, Jaqen Nki <proj...@gmail.com <javascript:>> 
> wrote: 
> > 
> >  So I take it for a new project, I repeat the process, new vhost and 
> .wsgi file, and create a wsgi.load file for each site? 
>
> The wsgi.load file should only have in it the LoadModule, WSGIPythonHome 
> and WSGIRestrictEmbedded directives. They applied to the server as a whole 
> and not specific VirtualHosts. 
>
> When you talk about adding more VirtualHost’s, that is when you will need 
> to be a bit careful with respect to virtual environments. 
>
> First up, a separate VirtualHost is used for each distinct site hostname. 
> Don’t use separate VirtualHost’s if only trying to mount different 
> applications at different sub URLs of the same site. Seen people try and 
> use multiple VirtualHost’s for same site hostname too many times. Is wrong 
> way. 
>
> Because you are going to have multiple VirtualHost’s would suggest doing 
> things a little differently. 
>
> First up, the wsgi.load file would only have LoadModule and 
> WSGIRestrictEmbedded directives in it. Not WSGIPythonHome. 
>
> In that file the WSGIPythonHome was acting as a fallback for both embedded 
> mode and daemon mode. With WSGIRestrictEmbedded set to On, don’t need the 
> fallback. Instead, we want to set python-home for each daemon process group 
> setup using WSGIDaemonProcess directive. 
>
> Thus: 
>
> # wsgi.load 
>
> LoadModule … 
> WSGIRestrictEmbedded On 
>
> # site1.conf 
>
> <VirtualHost *:80> 
> ServerName site1.host.name 
>
> WSGIDaemonProcess site1 python-home=/some/path/site1/venv 
> WSGIProcessGroup site1 
> WSGIApplicationGroup %{GLOBAL} 
>
> WSGIScriptAlias / /some/path/site1/app.wsgi 
>
> ... 
> </VirtualHost> 
>
> # site2.conf 
>
> <VirtualHost *:80> 
> ServerName site2.host.name 
>
> WSGIDaemonProcess site2 python-home=/some/path/site2/venv 
> WSGIProcessGroup site2 
> WSGIApplicationGroup %{GLOBAL} 
>
> WSGIScriptAlias / /some/path/site1/app.wsgi 
>
> ... 
> </VirtualHost> 
>
> If you do need to host multiple applications under same VirtualHost at 
> different sub URLs, you would use something like: 
>
> # site3.conf 
>
> <VirtualHost *:80> 
> ServerName site3.host.name 
>
> WSGIDaemonProcess site3_main python-home=/some/path/site3_main/venv 
> WSGIDaemonProcess site3_suburl python-home=/some/path/site3_suburl/venv 
>
> WSGIProcessGroup site3 
> WSGIApplicationGroup %{GLOBAL} 
>
> WSGIScriptAlias /suburl /some/path/site3_suburl/app.wsgi 
> process-group=site3_suburl 
> WSGIScriptAlias / /some/path/site3_main/app.wsgi 
>
> ... 
> </VirtualHost> 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to modwsgi+unsubscr...@googlegroups.com.
To post to this group, send email to modwsgi@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to