Install Trac In Ubuntu

本文由Mr_Willy原创,转载请注明出处。


一.安装trac:

$  sudo apt-get installpython-setuptools

$  sudo easy_install Trac

二.建立trac工程:

$  sudo -u www-data trac-adminproject initenv//以www-data身份创建一个工程

如图:

 

其中输入你的工程名信息,接着提示数据库选择,直接回车,使用mysql://root:root@localhost/project

提示:svn的库目录信息,这个以后可以通过修改conf/trac.ini来配置,也可以通过webAdmin进行配置,回车:

 


trac成功创建完之后,需要配置权限,是apache用户能够read和write,执行命令:

$ sudo chown -R www-data.www-data /home/trac/project/*

 

三.trac与apache的集成

官方已经不推荐trac与apache通过mod_python集成,推荐使用mod_wsgi.


3.1首先安装mod_wsgi

$sudo apt-cache search mod_wsgi


选择明显的一个

$sudo apt-get install libapache2-mod-wsgi

 

3.2在项目根目录下创建trac.wsgi文件,这是一个Python文件:

import os
os.environ['TRAC_ENV'] = '/path/to/trac'
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
import trac.web.main
application = trac.web.main.dispatch_request


根据下面的官方文档选择性配置:

The TRAC_ENV variable should naturally be thedirectory for your Trac environment (if you have several Trac environments in adirectory, you can also use TRAC_ENV_PARENT_DIRinstead), while the PYTHON_EGG_CACHE should be adirectory where Python can temporarily extract Python eggs.

 

3.3 Apache配置,将以下代码放入httpd.conf:

 

WSGIScriptAlias/trac /path/to/trac/trac.wsgi
<Directory/path/to/trac>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>


3.4创建验证(使用基础验证HTTP)

Thesimplest way to enable authentication with Apache is to create a password file.Use the htpasswd program to create the password file:

 

$ htpasswd -c /somewhere/trac.htpasswd admin

Newpassword: <type password>

Re-typenew password: <type password again>

Addingpassword for user admin

 

Afterthe first user, you dont need the "-c" option anymore:

 

$ htpasswd /somewhere/trac.htpasswd willy

Newpassword: <type password>

Re-typenew password: <type password again>

Addingpassword for user willy

Seethe man page for htpasswd for full documentation.

 

Afteryou've created the users, you can set their permissions using TracPermissions.

 

然后在httpd.conf中添加验证的配置

<Location"/trac/login">
  AuthType Basic
  AuthName "Trac"
  AuthUserFile /somewhere/trac.htpasswd
  Require valid-user
</Location>


如果有多个项目,可以用同一个验证信息来验证

<LocationMatch"/trac/[^/]+/login">
  AuthType Basic
  AuthName "Trac"
  AuthUserFile /somewhere/trac.htpasswd               #通常需要修改这个文件为可修改的
  Require valid-user
</LocationMatch>

3.5授权管理员

$ trac-admin/path/to/projenv



Trac[/home/trac/utc]> permission add admin TRAC_ADMIN


四.安装插件

4.1 Account ManagerPlugin:http://trac-hacks.org/wiki/AccountManagerPlugin


4.2使用http的基础验证不太灵活,也不能用户自己注册,安装Account Manager Plugin可以解决这个问题。可以下载源码egg安装也可以用easy_install。


4.2.1使用源码安装

cd accountmanagerplugin/

python ./setup.py compile_catalog -f

python ./setup.py bdist_egg


4.2.2以管理员的身份在后台中安装


4.3使用LoginForm来代替http的基础验证:


4.3.1首先要将上一个步骤中的httpd.conf中的Requirevalid-user注释掉或者删除。


4.3.2在conf/trac.ini中添加并启用此插件

[components]
trac.web.auth.LoginModule= disabled                           #关闭Http验证
acct_mgr.web_ui.LoginModule= enabled                 #开启LoginForm
acct_mgr.web_ui.RegistrationModule= enabled              #开启注册模块

如下图:





注:任何一次修改trac.ini都必须重启apache

五.发布

5.1建立符号链接

$ sudo ln –s/home/trac/ /var/www/trac


5.2重新启动apache

$ sudo/etc/init.d/apache2 restart


5.3浏览器访问即可显示所有的项目

http://localhost/trac


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值