Good day, im trying to deploy a server on CentOs7 in combination
Flask+Apache 2.4+mod_wsgi 4.5.5. Mod_wsgi was compiled with python 3.5.2
and test-run from manual works fine. However when i tried to connect mine
app i failed so i reduced tests to only Apache+mod_wsgi stack and found
that somehow import of python modules isnt working. The simplest test ive
run is - ive got folder with wsgi file and some function deployed in the
same folder.
insides of simple_app.wsgi:
---------------------------
import sys, os
sys.path.insert(0,os.getcwd())
import add
def application(environ, start_response):
status = '200 OK'
output = add.echo()
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
-------------------------
insides of add.py:
-------------------------
def echo():
return b'module import is fine'
-------------------------
Apache VirtualHost config:
-------------------------
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/html
WSGIScriptAlias /test /var/www/wsgi-scripts/simple_app.wsgi
<Directory /var/www/wsgi-scripts>
Require all granted
</Directory>
</VirtualHost>
Apache logs are telling:
...
[wsgi:error] [pid 11717] [client 83.220.186.194:56534] ImportError: no
module named 'add'
...
If i will leave the same Apache config, remove importing stuff from
simple_app.wsgi and as a result will return some byte string, like in this
code:
def application(environ, start_response):
status = '200 OK'
output = b'Hello, World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
everything will work just fine without errors and by opening
www.example.com/test i will see
"Hello, World!"
Since im totally newbie in Apache/mod_wsgi stuff all suggestions are
welcome!
--
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.