按照本指南,我在 Debian 服务器上设置了带有 Apache 和 mod_wsgi 的 Mailman 3。
我的虚拟主机的 .conf 文件:
ErrorLog /var/log/mailman-web/mailman-web.log
CustomLog /var/log/mailman-web/mailman-web_access.log combined
WSGISocketPrefix run/wsgi
<VirtualHost *:80>
ServerName XXXXXXX
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Here, use the value of the STATIC_ROOT variable in your Django configuration file (production.py)
Alias /robots.txt /usr/local/mailman/mailman-bundler/var/mailman-web/static/hyperkitty/robots.txt
Alias /favicon.ico /usr/local/mailman/mailman-bundler/var/mailman-web/static/hyperkitty/favicon.ico
Alias /static /usr/local/mailman/mailman-bundler/var/mailman-web/static
<Directory "/usr/local/mailman/mailman-bundler/var/mailman-web/static">
Order deny,allow
Allow from all
Require all granted
</Directory>
WSGIScriptAlias / /usr/local/mailman/mailman-bundler/bin/mailman-web.wsgi
WSGIDaemonProcess mailman-web display-name=mailman-web maximum-requests=1000 processes=1 threads=1 python-path=/usr/local/mailman/venv/lib/python2.7/site-packages
<Directory "/usr/local/mailman/mailman-bundler/bin">
<Files mailman-web.wsgi>
Order deny,allow
Allow from all
Require all granted
</Files>
WSGIProcessGroup mailman-web
</Directory>
</VirtualHost>
这个设置的问题是,当我转到http://myhost/
wsgi 脚本时,我的浏览器会重定向到http://myhost/archives
. 我想http://myhost/
重定向到http://myhost/mailman3
而不是http://myhost/archives
。
试图找出 mailman 决定在哪里返回档案子目录,我查看了 apache .conf 文件中定义的 wsgi 脚本,但是在导入一些类并调用另一个脚本之后并没有发生更多事情。按照这个脚本,我进入了文件'./eggs/Django-1.10.4-py2.7.egg/django/core/handlers/wsgi.py`,特别是这部分:
148 class WSGIHandler(base.BaseHandler):
149 request_class = WSGIRequest
150
151 def __init__(self, *args, **kwargs):
152 super(WSGIHandler, self).__init__(*args, **kwargs)
153 self.load_middleware()
154
155 def __call__(self, environ, start_response):
156 set_script_prefix(get_script_name(environ))
157 signals.request_started.send(sender=self.__class__, environ=environ)
158 try:
159 request = self.request_class(environ)
160 except UnicodeDecodeError:
161 logger.warning(
162 'Bad Request (UnicodeDecodeError)',
163 exc_info=sys.exc_info(),
164 extra={
165 'status_code': 400,
166 }
167 )
168 response = http.HttpResponseBadRequest()
169 else:
170 response = self.get_response(request)
171
172 response._handler_class = self.__class__
173
174 status = '%d %s' % (response.status_code, response.reason_phrase)
175 response_headers = [(str(k), str(v)) for k, v in response.items()]
176 for c in response.cookies.values():
177 response_headers.append((str('Set-Cookie'), str(c.output(header=''))))
178 start_response(force_str(status), response_headers)
179 if getattr(response, 'file_to_stream', None) is not None and environ.get('wsgi.file_wrapper'):
180 response = environ['wsgi.file_wrapper'](response.file_to_stream)
181 return response
我想返回的子目录的决定发生在这里的某个地方,但我可能是错的,不确定。
到目前为止我尝试了什么:在 apache conf 文件中,我添加了一行Redirect permanent / http://myhost/mailman3
,但这使得 apache 进入一个以 url 结尾的重定向循环,例如http://myhost/mailman3mailman3mailman3....
我希望有人可以帮助我解决这个问题。
提前致谢!