I'm using webapp2
to develop my app and I want to deploy it on apache using mod_wsgi
but I'm getting 500 Internal server Error along with import webapp2 no module found error in error_log.
I installed WebOb
, Paste
, webapp2
on to the system as well as in virtualenv
and tested on python environment
>> import webapp2
and it's working fine.
Error is:
> mod_wsgi (pid=15727): Target WSGI script '/var/www/html/app/main.py'
> cannot be loaded as Python module.
> mod_wsgi (pid=15727): Exception occurred processing WSGI script '/var/www/html/app/main.py'.Traceback (most recent call last):File
> "/var/www/html/app/main.py", line 20, in <module>
> import webapp2
My httpd.conf
file configuration is below
WSGISocketPrefix /var/run/wsgi
WSGIPythonPath /var/www/html/app/env/lib/python2.7/site-packages
<VirtualHost 10.10.10.9>
ServerName prep2016.msitprogram.net
ServerAlias prep2016.msitprogram.net
ServerAdmin sirimala.sreenath@gmail.com
# DocumentRoot /var/www/html/app
#WSGIDaemonProcess app python-path=/var/www/html/app:/var/www/html/app/env/lib/python2.7/site-packages
WSGIDaemonProcess prep2016.msitprogram.net processes=2 threads=15
WSGIScriptAlias / /var/www/html/app/main.py
<Directory /var/www/html/app/>
# options +ExecCGI
# DirectoryIndex main.py
# Order allow,deny
# Allow from all
# </Directory>
# DocumentRoot /var/www/html/app
# WSGIDaemonProcess prep2016.msitprogram.net processes=2 threads=15
#WSGIDaemonProcess prep2016.msitprogram.net user=apache group=apache processes=2 threads=15
WSGIProcessGroup prep2016.msitprogram.net
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
# WSGIScriptAlias / /var/www/html/app/main.py
# WSGIPythonPath /var/www/html/app
# <Directory /var/www/html/app>
# <Files main.py>
Order allow,deny
Allow from all
# Require all granted
# </Files>
</Directory>
</VirtualHost>
This is my main.py
file content
#!/usr/bin/env python
import os
import webapp2
import jinja2
import logging
import json
import datetime
import jwt.api_jwt
import os, sys
ABSPATH = os.path.dirname (__ file__)
sys.path.append (ABSPATH)
os.chdir (ABSPATH)
sys.path.append('/var/www/html/app/env/lib/python2.7/site-packages')
#site.addsitedir('/var/www/html/app/env/lib/python2.7/site-packages')
class MainPage(Webapp2.RequestHandler):
def get(self):
self.response.out.write("hello world")
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
def main():
from paste import httpserver
httpserver.serve(app, host='prep2016.msitprogram.net', port='8080')
if __name__ == '__main__':
main()