问题描述
我正在新的 RHEL 8 服务器上安装 Trac,但在 httpd 错误日志中收到内部服务器错误:
ModuleNotFoundError: No module named 'trac'
我试过用
查看审计日志journal -xe | grep httpd
(也为 trac 和 apache grepped) - 并且在那里显示零错误信息。
httpd
正常启动,没有错误。
Trac 配置为使用 wsgi,它不是具有自己内置服务器的独立版本。 Apache HTTPD 应该是错误处理。
这是 httpd trac.conf 文件:
WsgiScriptAlias /trac /data/www/virtualhosts/trac/cgi-bin/trac.wsgi
<Location "/trac/login">
AuthType Basic
AuthName "Issue Tracker"
AuthUserFile /data/www/virtualhosts/trac/conf/trac.htpasswd
Require valid-user
</Location>
<Directory /data/www/virtualhosts/trac/cgi-bin>
WsgiApplicationGroup %{GLOBAL}
# For Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Allow from all
</IfModule>
# For Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
和 trac.wsgi
import os
def application(environ,start_request):
if not 'trac.env_parent_dir' in environ:
environ.setdefault('trac.env_path','/data/www/virtualhosts/trac')
if 'PYTHON_EGG_CACHE' in environ:
os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
elif 'trac.env_path' in environ:
os.environ['PYTHON_EGG_CACHE'] = \
os.path.join(environ['trac.env_path'],'.egg-cache')
elif 'trac.env_parent_dir' in environ:
os.environ['PYTHON_EGG_CACHE'] = \
os.path.join(environ['trac.env_parent_dir'],'.egg-cache')
from trac.web.main import dispatch_request
return dispatch_request(environ,start_request)
python 版本
[user@Box] # python --version
Python 2.7.17
我不知道为什么我无法获得任何错误信息以显示在屏幕上或最好写入日志文件。此服务器尚未投入生产,因此我现在可以在屏幕上显示内容。
非常感谢任何帮助
解决方法
问题可能是对 cgi-bin
目录或其父目录之一的权限。
trac-admin
deploy
命令将为您创建一个 trac.wsgi
,但您需要部署在您的环境目录之外,否则,您将收到此错误:
Error: Resources cannot be deployed to a target directory that is equal to or below the source directory '/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.4/htdocs'.
Please choose a different target directory and try again.
如果您的环境是 /data/www/virtualhosts/trac
,请运行:
$ trac-admin /data/www/virtualhosts/trac deploy /data/www/virtualhosts/www
然后将您的虚拟主机文件指向 /data/www/virtualhosts/www/cgi-bin/trac.wsgi
。