> On 31 Jan 2018, at 9:33 am, st003 <[email protected]> wrote:
> 
> I am migrating my first flask app to an ubuntu VPS and I figured I’d get a 
> simple “Hello, word!” app running before trying to migrate more complex code. 
> Unfortunately, configuring mod_wsgi has stopped me dead.
> 
> 
> 
> System specs:
> 
> Ubuntu 16.04
> 
> Apache2.4
> 
> Python3.6
> 
> 
> 
> I plan to use this VPS for multiple small webapps long-term, so I used 
> virtualenv to create a virtual environment in the webapp’s root, installed 
> flask, and dropped in my “hello world” app per flask’s documentation. Using 
> flask’s dev server, I confirmed the virtual environment and flask are both 
> working properly.
> 
> 
> 
> I begin configuring my virtual host in apache, but this where things started 
> to get tricky. Unfortunately, the “sudo apt-get install 
> libapache2-mod-wsgi-py3” command installs a version of mod_wsgi compiled for 
> python3.5 which will not work in an environment running python3.6 (I tried).
> 
> 
> 
> After reading the documentation over at 
> http://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html
>  
> <http://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html>
>  and https://pypi.python.org/pypi/mod_wsgi 
> <https://pypi.python.org/pypi/mod_wsgi>, I decide that installing mod_wsgi 
> directly into my virtual environment using pip would provide me the most 
> flexibility. I confirmed a successful installation into my virtual 
> environment using “mod_wsgi-express start-server”.
> 
> 
> 
> Here’s where I get stuck. Obviously, I need to tell apache where my mod_wsgi 
> installation is, but the referenced documentation gets pretty vague in this 
> area. Here are the questions I’m struggling with:
> 
> 
> If mod_wsgi is located in my virtual environment, how do the instructions for 
> configuring a virtual host at 
> http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html
>  
> <http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html>
>  apply?
If you copy the output from mod_wsgi-express module-config into the Apache 
configuration, it will already be set up to use that virtual environment. That 
is what the WSGIPythonHome directive in the output will do. So isn't strictly 
necessary to also set python-home on the WSGIDaemonProcess directive, although 
I would still recommend it to avoid confusion if you decide to create a second 
daemon process group which points at a different Python virtual environment (of 
same Python version) for a specific application so it can have separate Python 
module versions.

Note that that first virtual environment with mod_wsgi installed in it is just 
a convenient home for the mod_wsgi Apache module. You could instead run 
mod_wsgi-express install-module and copy the module into the Apache 
installation, using the output from that command instead in the Apache 
configuration. It is recommended in that case (actually probably should always 
do it), to set WSGIRestrictEmbedded On outside of VirtualHost to disable 
embedded mode of mod_wsgi and always force use of daemon mode. The 
WSGIPythonHome doesn't really matter then, and can set just python-home on each 
WSGIDaemonProcess to refer to each applications separate virtual environment.
> https://pypi.python.org/pypi/mod_wsgi <https://pypi.python.org/pypi/mod_wsgi> 
> seems to indicate that I should to copy the “mod_wsgi-express module-config” 
> output into a wsgi.load file in apache, but wouldn’t that defeat the purpose 
> of installing mod_wsgi into a virtual environment in the first place? What If 
> I wanted to run a parallel app on this VPS using python2.7? Or python3.7 in 
> the future?
You can't do that anyway. The mod_wsgi module gets loaded direct into Apache 
and the way things work you can therefore only use the one Apache instance with 
one Python version at a time. If you wanted to use multiple Python versions you 
could run instances of mod_wsgi-express start-server separate and proxy to them 
from the front end Apache.
> How can I make sure apache recognizes my mod_wsgi installation in the virtual 
> environment so that after I enable the app's virtual host, apache will 
> restart properly?
Using output from mod_wsgi-express module-config should be sufficient. Perhaps 
try it and if have issue then explain the specific problem you are having.
> Any direction on linking a mod_wsgi virtual environment installation to 
> apache2.4 would be most helpful. Thanks in advance.
> 
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.

Reply via email to