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 Thursday, May 12, 2016 at 1:52:25 AM UTC-7, Graham Dumpleton wrote:
>
>
> > On 12 May 2016, at 6:32 PM, Jaqen Nki <[email protected] <javascript:>>
> wrote:
> >
> > Ok my bad, I figured it would be good idea to avoid posting
> redundancies. After much struggle GOOD NEWS IT WORKS! This is awesome,
> just tested it after reboot linux, it autoserves perfectly. 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>
>
>
> > Either way I have it all logged in a file so I know exactly what to do
> next time. I have two concise guide txt files for setting up a python3
> flaskapp on ubuntu server now, one with and one without a venv
> configuration- if you want to post them in mod wsgi docs as easy setup
> guides to help other people, let me know (honestly a lot of stuff in the
> docs is unnecessary and not to the point, one can get lost in the
> convolution). Thanks so much for bearing with me man you are a lifesaver
> and a brilliant programmer, and Im curious to know what projects youre
> working on or have worked on.
>
> The docs are a mess right now, I acknowledge that. The effort required to
> bring them up to date and better organise them is substantial and more
> interested in other stuff right now.
>
> > Im going to throw you an amazon gift card code after I can get to
> the store soon, for the almost instantaneous responses and solving my
> problems every time - like do you even sleep? haha. Also Ill show you my
> finished web sites once they are live because they are pretty slick and
> theyre my first projects in web development, of which Im proud. It may be
> a couple months but one of the sites is for an upcoming game mod of
> warcraft 3 (best RTS of all time), which is being cloned to the starcraft 2
> engine because the old engine is outdated and clunky - called Armies of
> Azeroth on moddb.com. Im probably going to have to resort to django as
> the go to framework since its more popular and most of the job postings I
> see are for django developers and rarely flask. Anyways cheers thanks
> again hope all is well in AU.
>
> If you are looking at Amazon gift card, that is much appreciated. Just
> note that it needs to be the US Amazon store. That store is only one I can
> readily use even though don’t Iive in the US. I travel there enough though
> to order stuff and send to friends in US and then pick it up. :-)
>
> Thanks.
>
> Graham
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.