【发布时间】:2018-10-05 14:24:00
【问题描述】:
在 Apache 上使用 Python Bottle 开发时遇到问题。每次我更改导入到主 app.wsgi 的文件 dbmanager.py 时,都没有任何变化。我需要“触摸”app.wsgi 以查看 dbmanager.py 中的更改或重新启动 apache。我尝试了一切:.htaccess 中的更改,apache 虚拟主机配置。但仍然没有。有什么想法吗?
我的文件的路径是:
/var/www/paka/public_html/edi/api/app.wsgi
我有两个文件:
app.wsgi
import os, sys
from os.path import dirname
sys.path.append(dirname(__file__))
import bottle
from bottle import route, run, template, post, request, response
bottle.debug(True)
bottle.TEMPLATES.clear()
import dbmanager
c = dbmanager.connect()
@route('/hello/<name>')
def index(name):
#return hello.world() # only log in console
return template('<b>Hello {{name}}</b>!' + c, name=name)
application = bottle.default_app()
和 dbmanager.py
import mysql, mysql.connector
def connect():
return "123456"
我的 .htaccess
# DISABLE CACHING
ExpiresActive On
ExpiresDefault A1
Header append Cache-Control must-revalidate
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|png|pdf|swf|txt|py|pcc)$">
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
<IfModule mod_headers.c>
FileETag None
Header unset ETag
Header unset Pragma
Header unset Cache-Control
Header unset Last-Modified
Header set Pragma "no-cache"
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Expires "Mon, 10 Apr 1972 00:00:00 GMT"
</IfModule>
</FilesMatch>
我的虚拟主机配置:
WSGIDaemonProcess bottle user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias / /var/www/paka/public_html/edi/api/app.wsgi
<Directory /var/www/paka/public_html/edi/api/>
WSGIProcessGroup bottle
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
【问题讨论】:
-
文件更改后尝试重启apache?
-
是的,当我重新启动 apache 时,我看到了变化。那么就没有其他选择了吗?修改文件后总是需要重启jeeves?
标签: python apache mod-wsgi wsgi bottle