Okay, I've install pymongo in my virtualenv using pip3, and when I try to load the pymongo module in my flask app (This only happen when I run it using my domain, I still be abble to run flask to my public IP) my the page return 500 Internal Server Error.
This is the error
[Sun Sep 02 02:32:52.289075 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] mod_wsgi (pid=4722): Target WSGI script '/var/www/mainyuk.andra.xyz/app.wsgi' cannot be loaded as Python module.
[Sun Sep 02 02:32:52.289139 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] mod_wsgi (pid=4722): Exception occurred processing WSGI script '/var/www/mainyuk.andra.xyz/app.wsgi'.
[Sun Sep 02 02:32:52.289229 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] Traceback (most recent call last):
[Sun Sep 02 02:32:52.289277 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] File "/var/www/mainyuk.andra.xyz/app.wsgi", line 5, in <module>
[Sun Sep 02 02:32:52.289286 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] from app import app as application
[Sun Sep 02 02:32:52.289299 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] File "/var/www/mainyuk.andra.xyz/app.py", line 3, in <module>
[Sun Sep 02 02:32:52.289305 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] from pymongo import MongoClient
[Sun Sep 02 02:32:52.289369 2018] [wsgi:error] [pid 4722] [remote 172.69.134.106:13286] ModuleNotFoundError: No module named 'pymongo'
The directory structure looks like this
var/www/mainyuk.andra.xyz
├── venv (Virtual environment)
| └── etc
├── app.wsgi
└── app.py
app.py
from flask import Flask, request
from pymongo import MongoClient
#Initializing Flask
app = Flask(__name__)
#Initializing MongoDB
#client = MongoClient('localhost', 27017)
#db = client.mainyuk
#dbColDevelopment = db.development
#Routing
@app.route('/')
def index():
return 'It works!'
@app.route('/webhook', methods=['GET', 'POST'])
def webhook():
#if 'events' in request.form:
# dbColDevelopment.insert_one({ "events" : request.form['events'] })
return ''
if __name__ == "__main__":
app.run(ssl_context=('../cert.pem', '../cert.private.pem'))
app.wsgi
import sys
sys.path.insert(0, '/var/www/mainyuk.andra.xyz/') #sys.path.append("/var/www/mainyuk.andra.xyz/")
from app import app as application
apache_configuration.conf
<VirtualHost *:80>
ServerAdmin admin@localhost
ServerName mainyuk.andra.xyz
ErrorLog /var/www/mainyuk.andra.xyz/error.log
CustomLog /var/www/mainyuk.andra.xyz/access.log combined
#WSGIPythonHome /var/www/mainyuk.andra.xyz/venv
#WSGIPythonPath /var/www/mainyuk.andra.xyz/venv/lib/python3.6/site-packages
#WSGIScriptReloading On
WSGIDaemonProcess app user=www-data group=www-data threads=5 python-home=/var/www/mainyuk.andra.xyz/venv
WSGIScriptAlias / /var/www/mainyuk.andra.xyz/app.wsgi
<Directory /var/www/mainyuk.andra.xyz>
WSGIProcessGroup app
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
# Alias /static/ /var/www/FLASKAPPS/helloworldapp/static
# <Directory /var/www/mainyuk.andra.xyz/>
# Order allow,deny
# Allow from all
# </Directory>
</VirtualHost>
Aucun commentaire:
Enregistrer un commentaire