我正在尝试使用wsgi在Ubuntu VPS中部署FLASK应用程序,但是我收到内部服务器错误。检查apache.log会出现以下错误:
没有这样的文件或目录:' files / filesystem / filesystem.pickle'。
我的目录树在/var/www/
下显示如下:
dmft_seacrh_engine
files
filesystem
filesystem.pickle
dmft_search.wsgi
dmft_search
controllers
search.py
我正在尝试打开filesystem.pickle
内的search.py
,如下所示:
with open('/files/filesystem/filesystem.pickle', 'rb') as handle:
filesystem = pickle.load(handle)
dmft.wsgi
文件的内容为:
activate_this = '/opt/dmft/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/dmft_search_engine")
from dmft_search import app as application
这就是我的conf文件的外观:
<VirtualHost *:80>
ServerName dmft_search_engine.com
WSGIScriptAlias / /var/www/dmft_search_engine/dmft_search.wsgi
<Directory /var/www/dmft_search_engine/dmft_search/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/dmft_search_engine/dmft_search/static
<Directory /var/www/dmft_search_engine/dmft_search/static/>
Order allow,deny
Allow from all
</Directory>
Alias /files /var/www/dmft_search_engine/files/$
<Directory /var/www/dmft_search_engine/files/>$
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
请帮助我。我还在.conf文件中添加了/files
的别名。
我该如何解决这个问题?
答案 0 :(得分:0)
问题是应用程序在根目录的上下文中运行 所以正确的路径应该是:
with open('var/www/html/dmft_search_engine/files/filesystem/filesystem.pickle', 'rb') as handle:
filesystem = pickle.load(handle)