在 Apache 中不设置 VirtualHost 的情况下安装 Trac?

job*_*324 4 configuration trac apache-2.2

我正在尝试设置 Trac 来测试它的功能,我可以在网上找到唯一的关于设置 VirtualHost 的指南。现在我的印象是我需要访问 DNS 服务器才能正确使用 VirtualHost 指令,但由于各种原因我无法访问。是否可以在不设置 VirtualHost 的情况下设置 Trac?我没有任何运气。如果我使用 tracd 运行该站点,它就可以工作 - 这意味着它至少有一部分设置正确。

现在我只有一个指向 /pathToTracSite/htdocs/ 的 Apache 目录指令,当我访问 trac 位置时,从浏览器查看站点时我得到的只是一个空目录(这是有道理的,因为 htdocs/ 是空的)。

我的服务器正在运行 Apache2

我知道我在这里遗漏了很多,因为我不太了解 Apache Trac 系统 - 任何帮助将不胜感激。

Wal*_*ter 9

如果你想让trac运行得更快,使用mod_wsgi(比mod_python快,两者都比CGI快)。这可以从源代码或二进制包(参见 yum 或 apt-get)安装为 apache 模块。安装 MoinMoin 时,我发现 mod_python 和 wsgi 之间的差异很重要。刚刚注意到,你的绊脚石是 python web 应用程序必须在运行之前在 Apache 中配置(它不像 PHP 或 CGI 应用程序那样工作)。

跟踪

为 WSGI 设置 trac:

  • 在您的 trac 安装 (mkdir /trac/apache) 中创建一个 apache 目录
  • 在 /trac/apache 中为 trac 创建一个 wsgi 文件(如下所列)
  • 在您的 trac 安装 (mkdir /trac/eggs) 中创建一个鸡蛋目录
  • 将以下内容添加到您的 apache conf(使用包含文件以提高可读性)
  • 将 trac 的所有权更改为 Web 服务器 (chown -R apache /trac)

阿帕奇配置文件


 WSGIScriptAlias /trac   /trac/apache/trac.wsgi

 ## This is required if you plan to use HTTP authorization. Without it the
 ## user name won't be passed
 WSGIPassAuthorization On

<Directory /trac/apache >
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
    AuthName "Trac at My Company"
    AuthType Basic
    AuthUserFile /var/secure/authfiles/trac-authfile
    Require valid-user
</Directory >
Run Code Online (Sandbox Code Playgroud)

trac.wsgi


import sys
sys.stdout = sys.stderr

import os
os.environ['TRAC_ENV'] = '/trac'
os.environ['PYTHON_EGG_CACHE'] = '/trac/eggs'

import trac.web.main

application = trac.web.main.dispatch_request
Run Code Online (Sandbox Code Playgroud)

要为 mod_python 设置 Trac,您可以按照TracModPython 中的说明进行操作,复制到此处以供您阅读:


<Location /projects/myproject>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend 
   PythonOption TracEnv /var/trac/myproject
   PythonOption TracUriRoot /projects/myproject
</Location>
Run Code Online (Sandbox Code Playgroud)