How did you install Python 3.6?

Unless that is a very up to date Ubuntu version, which I would doubt AWS would 
be using if this is one of their images, you would need to install it from 
source code. Installing Python from source code yourself can be a bit tricky on 
Linux as the default configure options aren't what you need. Also not a good 
idea to install from Python source code into system directories as it is then 
hard to extract it out if you need to remove it.

> On 14 Jun 2018, at 3:33 pm, Rajeev Jain <[email protected]> wrote:
> 
> Latest update:
> 
> No virtual environment. Python3.6 is now installed into the system folder:
> 
> python location:
> /etc/apache2/sites-available$ python --version
> Python 3.6.5
> 
> python
> Python 3.6.5 (default, May  3 2018, 10:08:28) 
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> print(sys.prefix)
> /usr
> 
> Flask location:
> >>> import flask
> >>> print(flask.__file__)
> /usr/local/lib/python3.6/dist-packages/flask/__init__.py
> 
> mod_wsgi-express module-config
> LoadModule wsgi_module 
> "/usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
> WSGIPythonHome "/usr"
> 
> cat wsgi.load 
> LoadModule wsgi_module 
> /usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
>  
> 
> /etc/apache2/sites-available$ cat FlaskApp.conf 
> <VirtualHost *:83>
> 
>     ServerName flaskapp.com <http://flaskapp.com/>
> 
>     WSGIDaemonProcess flaskapp.com <http://flaskapp.com/> python-home=/usr 
> python-path=/var/www/FlaskApp
> 
>     WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi 
> process-group=flaskapp.com <http://flaskapp.com/> application-group=%{GLOBAL}
> 
>     <Directory /var/www/FlaskApp/>
>     <Files flaskapp.wsgi>
>     Require all granted
>     </Files>
>     </Directory>
> 
> </VirtualHost>
> 
> /etc/apache2/mods-available$ cat wsgi.conf
> <IfModule mod_wsgi.c>
> 
>     WSGIRestrictEmbedded On
> 
> </IfModule>
> 
> Testing:
> curl -sH 'Host: flaskapp.com <http://flaskapp.com/>' localhost:83|grep title
> <title>500 Internal Server Error</title>
> 
> tail -l /var/log/apache2/error.log
> [Wed Jun 13 22:18:08.678744 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]     from werkzeug.exceptions import abort
> [Wed Jun 13 22:18:08.678749 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]   File 
> "/usr/local/lib/python3.6/dist-packages/werkzeug/__init__.py", line 151, in 
> <module>
> [Wed Jun 13 22:18:08.678752 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]     __import__('werkzeug.exceptions')
> [Wed Jun 13 22:18:08.678756 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]   File 
> "/usr/local/lib/python3.6/dist-packages/werkzeug/exceptions.py", line 67, in 
> <module>
> [Wed Jun 13 22:18:08.678759 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]     from werkzeug._internal import _get_environ
> [Wed Jun 13 22:18:08.678764 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]   File 
> "/usr/local/lib/python3.6/dist-packages/werkzeug/_internal.py", line 15, in 
> <module>
> [Wed Jun 13 22:18:08.678766 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]     from datetime import datetime, date
> [Wed Jun 13 22:18:08.678771 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]   File "/usr/lib/python3.6/datetime.py", line 8, in <module>
> [Wed Jun 13 22:18:08.678773 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590]     import math as _math
> [Wed Jun 13 22:18:08.678786 2018] [wsgi:error] [pid 3095] [remote 
> 127.0.0.1:57590] ModuleNotFoundError: No module named 'math'
> 
> Running FlaskApp on its own:
> /var/www/FlaskApp/FlaskApp$ python __init__.py 
>  * Serving Flask app "__init__" (lazy loading)
>  * Environment: production
>    WARNING: Do not use the development server in a production environment.
>    Use a production WSGI server instead.
>  * Debug mode: off
>  * Running on http://127.0.0.1:5000/ <http://127.0.0.1:5000/> (Press CTRL+C 
> to quit)
> 127.0.0.1 - - [13/Jun/2018 22:25:23] "GET / HTTP/1.1" 200 -
> 127.0.0.1 - - [13/Jun/2018 22:25:23] "GET /favicon.ico HTTP/1.1" 404 -
> 
> curl -sH 'Host: flaskapp.com <http://flaskapp.com/>' localhost:5000
> Hello, this is running from flasK!
> 
> As you can see the FlaskApp is running fine.
> Python and all modules are now installed in system locations and they are 
> running fine.
> Apache2 is running fine. I have 2 other virtualhosts running serving php/html 
> pages
> 
> Still WSGI is still not setup correctly.
> 
> I'm shocked at the lack of decent documentation to get WCGI enabled on a 
> Apache2 server. What am I missing??

There is a whole web site on it at:

http://modwsgi.readthedocs.io/en/develop/ 
<http://modwsgi.readthedocs.io/en/develop/>

It just doesn't cover the specifics of particular ways that Linux distros need 
things done because they depart from standard conventions for Apache and do 
things their own way. Lot of work to document how every different Linux distro 
does it.

> Don't you have some basic test code or files one can run to verify the WSGI 
> is setup correctly?

Usually if you can get the WSGI hello world program working you are good.

* 
http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html
 
<http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html>

There are various checks you can run in:

* 
http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html
 
<http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html>

This more for when debugging issues when things don't work.

Graham

> 
> Please advise.
> --Rajeev
> 
> 
>  
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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