Я совершенно новичок в развертывании и разработке Python / Flask. Хотя я понимаю язык Python 3.x, я не понимаю процесс WSGI для развертывания Flask. Я продолжаю получать синтаксическую ошибку после следующих этой документации . Может кто-нибудь объяснить мне, что я делаю неправильно, и, что более важно, что на самом деле делает WSGI, отличается от, скажем, развертывания PHP-кода, поэтому я могу понять , почему что я делаю неправильно?
Файл WSGI:
#! /usr/bin/python3.6
activate_this = '/var/www/venv/bin/activate'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
import sys
sys.path.insert(0, '/var/www/html')
import logging
from my_flask_app import app as application
application.secret_key = 'anything you wish'
Apache / VHost:
<VirtualHost *:80>
ServerName cs2api.stonemor.local
WSGIDaemonProcess my_flask_app user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/html/my_flask_app.wsgi
<Directory /var/www/html/>
WSGIScriptReloading On
WSGIProcessGroup my_flask_app
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Журнал ошибок:
[Wed Oct 23 13:29:45.043034 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54458] SyntaxError: invalid syntax
[Wed Oct 23 13:29:45.083906 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] mod_wsgi (pid=73): Target WSGI script '/var/www/html/my_flask_app.wsgi' cannot be loaded as Python module.
[Wed Oct 23 13:29:45.083930 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] mod_wsgi (pid=73): Exception occurred processing WSGI script '/var/www/html/my_flask_app.wsgi'.
[Wed Oct 23 13:29:45.083949 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] Traceback (most recent call last):
[Wed Oct 23 13:29:45.083968 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] File "/var/www/html/my_flask_app.wsgi", line 4, in <module>
[Wed Oct 23 13:29:45.084398 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] exec(file_.read(), dict(__file__=activate_this))
[Wed Oct 23 13:29:45.084446 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] File "<string>", line 4
[Wed Oct 23 13:29:45.084452 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] deactivate () {
[Wed Oct 23 13:29:45.084456 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] ^
[Wed Oct 23 13:29:45.084459 2019] [wsgi:error] [pid 73] [remote 172.23.0.1:54460] SyntaxError: invalid syntax