I recently posted this question to clear a hurdle in launching a Flask webapp on my Amazon ec2 RedHat 7 instance.
In brief, I am attempting to launch a Flask webapp via an Anaconda environment using Python 3.6. Currently, I have a simple Hello World Flask application in /var/www/html/example, following the instructions found here. I was able to run this script previously, using the pre-installed Python 2.7.5 (found at /usr/bin/python), and since have been attempting to run the same application using Python 3.6.
I have been referring to multiple posts regarding similar issues, including this, this, and this, but I am still a bit lost.
I have configured mod_wsgi via the conda environment (for 3.6).
Some relevant system information:
$ which python
~/anaconda3/envs/myenv/bin/python (abspath is /home/ec2-user/anaconda3/envs/myenv/bin/python)
$ python -V
Python 3.6.2 :: Continuum Analytics, Inc.
$ which mod_wsgi-express
~/anaconda3/envs/myenv/bin/mod_wsgi-express
$ mod_wsgi-express module-config
LoadModule wsgi_module "/home/ec2-user/anaconda3/envs/myenv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome "/home/ec2-user/anaconda3/envs/myenv"
The contents of file /etc/httpd/conf/httpd.conf:
DocumentRoot "/var/www/html"
WSGIDaemonProcess myenv python-path=/home/ec2-user/anaconda3/envs/myenv/lib/python3.6/site-packages
WSGIScriptAlias / /var/www/html/examples/example.wsgi process-group=myenv application-group=%{GLOBAL}
LoadModule wsgi_module "/home/ec2-user/anaconda3/envs/myenv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome /home/ec2-user/anaconda3/envs/myenv
<Directory example>
WSGIProcessGroup myenv
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
Upon attempting to run sudo apachectl restart, I receive this output of systemctl status httpd.service:
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2018-04-08 21:41:38 UTC; 3min 7s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 20541 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 20540 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 20540 (code=exited, status=1/FAILURE)
Apr 08 21:41:38 [ip].compute.internal systemd[1]: Starting The Apache HTTP Server...
Apr 08 21:41:38 [ip].compute.internal httpd[20540]: httpd: Syntax error on line 125 of /etc/httpd/conf/httpd.conf: Cannot load /home/ec2-user/anaconda3/envs/myenv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so into server: : /home/ec2-user/anaconda3/envs/myenv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so: cannot open shared object file: Permission denied
The file in question (mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so) has executable permissions for all users.
I've also noticed that /var/log/httpd/error_log is outputting ImportError: No module named site, despite the fact that I am not attempting to import the site module in any Python file within /var/www/html/example.