Я пытаюсь запустить приложение "hello world" python с сервера, используя Apache порт 80 веб-сервера. Здесь у меня настроена виртуальная среда python, сжатая с python версии 3.8. создал виртуальный хост, файл wsgi и теперь пытаюсь вызвать URL в браузере, я получаю 500 внутренних ошибок сервера. Apache подробности файла журнала ошибок приведены здесь.
1. Ubuntu 18.04,
2. Python 3.8,
3. Apache 2.4
Virtual host configuration
#WSGIDaemonProcess MyApp python-home=/usr/local/env/myApp/venv threads=5i
WSGIDaemonProcess Myapp user=www-data group=www-data python-home=/usr/local/env/myApp/venv python-path=/usr/local/env/myApp threads=5
WSGIScriptAlias /project_wsgi /usr/local/env/myApp/myapp.wsgi
#WSGIProcessGroup myApp
WSGIApplicationGroup Myapp
#WSGIImportScript %{GLOBAL}
#WSGIPythonHome /usr/local/env/myApp/venv
<VirtualHost *:80>
<Directory /usr/local/env/myApp>
Require all granted
Order allow,deny
Allow from all
LogLevel info
</Directory>
</VirtualHost>
WSGI file
import os
import sys
sys.path.insert(0, '/usr/local/env/myApp/')
python_home = '/usr/local/env/myApp/venv'
#activate_this = '/usr/local/env/myApp/venv/bin/activate_this.py'
#with open(activate_this) as file_:
# exec(file_.read(), dict(__file__=activate_this))
from app.myApp import app as application
apache error logs
[Fri Jan 31 16:00:28.990978 2020] [wsgi:info] [pid 58589:tid 140712013437888] mod_wsgi (pid=58589): Starting process 'Myapp' with uid=33, gid=33 and threads=5.
[Fri Jan 31 16:00:28.991819 2020] [wsgi:info] [pid 58589:tid 140712013437888] mod_wsgi (pid=58589): Python home /usr/local/env/myApp/venv.
[Fri Jan 31 16:00:28.991863 2020] [wsgi:info] [pid 58589:tid 140712013437888] mod_wsgi (pid=58589): Initializing Python.
[Fri Jan 31 16:00:28.991926 2020] [mpm_event:notice] [pid 102854:tid 140712013437888] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Jan 31 16:00:28.991937 2020] [mpm_event:info] [pid 102854:tid 140712013437888] AH00490: Server built: 2019-09-16T12:58:48
[Fri Jan 31 16:00:28.991952 2020] [core:notice] [pid 102854:tid 140712013437888] AH00094: Command line: '/usr/sbin/apache2'
[Fri Jan 31 16:00:28.993170 2020] [wsgi:info] [pid 58591:tid 140712013437888] mod_wsgi (pid=58591): Initializing Python.
[Fri Jan 31 16:00:28.993874 2020] [wsgi:info] [pid 58590:tid 140712013437888] mod_wsgi (pid=58590): Initializing Python.
[Fri Jan 31 16:00:29.061111 2020] [wsgi:info] [pid 58589:tid 140712013437888] mod_wsgi (pid=58589): Attach interpreter ''.
[Fri Jan 31 16:00:29.088271 2020] [wsgi:info] [pid 58589:tid 140712013437888] mod_wsgi (pid=58589): Adding '/usr/local/env/myApp' to path.
[Fri Jan 31 16:00:29.089075 2020] [wsgi:info] [pid 58591:tid 140712013437888] mod_wsgi (pid=58591): Attach interpreter ''.
[Fri Jan 31 16:00:29.089966 2020] [wsgi:info] [pid 58590:tid 140712013437888] mod_wsgi (pid=58590): Attach interpreter ''.
[Fri Jan 31 16:02:22.375687 2020] [wsgi:info] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] mod_wsgi (pid=58591, process='', application='Myapp'): Loading WSGI script '/usr/local/env/myApp/myapp.wsgi'.
[Fri Jan 31 16:02:22.381101 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] mod_wsgi (pid=58591): Target WSGI script '/usr/local/env/myApp/myapp.wsgi' cannot be loaded as Python module.
[Fri Jan 31 16:02:22.381132 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] mod_wsgi (pid=58591): Exception occurred processing WSGI script '/usr/local/env/myApp/myapp.wsgi'.
[Fri Jan 31 16:02:22.381374 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] Traceback (most recent call last):
[Fri Jan 31 16:02:22.381400 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] File "/usr/local/env/myApp/myapp.wsgi", line 10, in <module>
[Fri Jan 31 16:02:22.381405 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] from app.myApp import app as application
[Fri Jan 31 16:02:22.381411 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] File "/usr/local/env/myApp/app/myApp.py", line 1, in <module>
[Fri Jan 31 16:02:22.381414 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] from flask import Flask
[Fri Jan 31 16:02:22.381436 2020] [wsgi:error] [pid 58591:tid 140711785658112] [client 146.176.178.57:50395] ModuleNotFoundError: No module named 'flask'
Я установил flask в виртуальной среде и пытаюсь выполнить активацию из файла WSGI. Однако, это не работает для меня.
К вашему сведению: закомментированные строки на виртуальном хосте уже пробовали.