我有一个Flask应用程序,我想在我们实验室网站的子域/非根URL上托管。例如,我希望mylab.com/portal引领烧瓶应用程序。我跟随了很多指南,但我一直收到404错误。
我的目录结构:
/var/www/
-html/
-Stuff for mylab.com
-FlaskApp/
-FlaskApp.wsgi
-FlaskApp/
-__init__.py
-static/
-templates/
-...
FlaskApp.wsgi:
#!/usr/bin/python3
activate_this = '/home/cogsci-cnddcollab/FlaskApp/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/var/www/FlaskApp')
from FlaskApp import app as application
/etc/apache2/sites-available/000-default.conf
WSGIRestrictStdout Off
WSGIScriptReloading On
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName mylab.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Redirect permanent / https://mylab.com/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory "/var/www/html">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
## FlaskApp
WSGIDaemonProcess FlaskApp_wsgi user=cogsci-cnddcollab group="domain users" threads=5
WSGIScriptAlias /portal /var/www/FlaskApp/FlaskApp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
WSGIProcessGroup FlaskApp_wsgi
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
Alias /portal/static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static>
Require all granted
</Directory>
Alias /portal/templates /var/www/FlaskApp/FlaskApp/templates
<Directory /var/www/FlaskApp/FlaskApp/templates>
Require all granted
</Directory>
</VirtualHost>
现在,当我重新启动apache2服务并转到mylab.com/portal时,我遇到了404错误。我已将APPLICATION_ROOT=/portal
添加到我的config.py文件中。
任何帮助将不胜感激。