I am working on a CentOS7 development environment. The machine came with Python 2.7.5 pre-installed. I have developed a web application using Python 3.5.1 which along with it's dependencies was installed in the virtual environment only. Python 3 is not installed machine-wide. I am now trying to deploy the application on an Apache server but have run into trouble. Here is what I have done.
I installed mod_wsgi using yum.
I configured the virtualhost as shown below:
<VirtualHost *:80>
ServerName myapp.myserver.com
WSGIDaemonProcess myapp user=myuser group=mygroup threads=5 python-path=/var/www/myapp.myserver.com/html:/var/www/myapp.myserver.com/venv/lib:/var/www/myapp.myserver.com/venv/lib/python3.5/site-packages python-home=/var/www/myapp.myserver.com/html/venv
WSGIScriptAlias / /var/www/myapp.myserver.com/html/myapp.wsgi
<Directory /var/www/myapp.myserver.com/html>
WSGIProcessGroup smex
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
My wsgi file is configured as shown below:
import sys
sys.path.insert(0, '/var/www/myapp.myserver.com/html')
activate_this = '/var/www/myapp.myserver.com/html/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
from myapp import app as application
However, I am getting an internal server error when I try to open the site. The error log reveals the following:
Tue Oct 18 14:24:50.174740 2016] [mpm_prefork:notice] [pid 27810] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Tue Oct 18 14:24:50.174784 2016] [core:notice] [pid 27810] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
The last error keeps repeating for most of the log file. The first thing that catches my eye is the Python version which seems to be 2.7.5. This brings me to my questions:
- Do I need to have Python 3.5.1 installed in /usr/local or can I just have it in the virtual environment.
- Do I need to install a specific mod_wsgi version for this version of Python? If so should I install it via pip instead of yum?
- What else am I missing to get this to work?
Thanks in advance for your help.