Date Tags trac

环境:

  • ubuntu : 10.04.04
  • trac : 1.0

安装

trac的安装路径是/opt/trac, 我们还是得使用vitualenv环境,

virtualenv-2.7 /opt/trac/env
cd /opt/trac
source env/bin/activate
pip install trac
pip install uwsgi

创建project

export YOUR_PROJECT_NAME=XXXXXXXXX
mkdir -p /opt/trac/projects
cd /opt/trac/projects
trac-admin ${YOUR_PROJECT_NAME} initenv

填写project name和db, 然后project就创建好了,目录在/opt/trac/projects/${YOUR_PROJECT_NAME},

主要的配置文件在/opt/trac/projects/${YOUR_PROJECT_NAME}/conf/trac.ini

delpoy这个project

trac-admin ${YOUR_PROJECT_NAME} deploy ${YOUR_PROJECT_NAME}/deploy

配置Nginx和uWSGI

创建nginx启动文件,编辑/opt/trac/trac_nginx.conf

server {
    listen          80;
    server_name     trac.folowing.com;
    access_log      /var/log/nginx/trac/access.log;

    location /chrome {
        alias /opt/trac/projects/${YOUR_PROJECT_NAME}/deploy/htdocs;
        add_header Cache-Control public;
        expires 1M;
    }

    location / {
        include     uwsgi_params;
        uwsgi_pass  unix:/tmp/trac.sock;
        uwsgi_modifier1 30;
    }
}

连接到/etc/nginx/conf.d

sudo ln -s /opt/trac/trac_nginx.conf /etc/nginx/conf.d/trac.conf

编辑/opt/trac/uwsgi.ini

[uwsgi]
socket = /tmp/trac.sock                                                          
virtualenv = /opt/trac/env
daemonize = /var/log/nginx/trac/uwsgi.log

master = true
processes = 2

enable-threads=true

wsgi-file=/opt/moin/env/share/moin/moin.wsgi

编辑/opt/trac/uwsgi.ini

[uwsgi]
socket = /tmp/trac.sock
virtualenv = /opt/trac/env
daemonize = /var/log/nginx/trac/uwsgi.log
#chdir = /opt/moin/env

master = true
processes = 2

enable-threads=true

wsgi-file=/opt/trac/projects/${YOUR_PROJECT_NAME}/deploy/cgi-bin/trac.wsgi

创建trac uwsgi的启动文件, /etc/init/trac.conf

start on runlevel [2345]
stop on runlevel [!2345]

respawn
expect daemon

instance trac
exec /opt/trac/env/bin/uwsgi --die-on-term --ini /opt/trac/uwsgi.ini --pidfile /var/run/trac.pid

post-stop script
    rm -f /var/run/trac.pid
end script

配置trac

创建admin用户到project里面

sudo /opt/trac/env/bin/trac-admin projects/${YOUR_PROJECT_NAME} permission add admin TRAC_ADMIN

为admin用户设置密码,还可以添加其他用户, 实用htpasswd的话要安装apache2-utils

sudo htpasswd -m .htpasswd admin

与mylyn集成

需要安装xmlrpc插件,根据此插件的安装页面提示,因为 AccountManagerPlugin的存在导致/login/xmlrpc会不好用,所以 安装后还得配置一下。

pip install svn+http://trac-hacks.org/svn/xmlrpcplugin/trunk/
pip install svn+http://trac-hacks.org/svn/httpauthplugin/trunk

编辑/opt/trac/projects/${YOUR_PROJECT_NAME}/conf/trac.ini

[components]
tracrpc.* = enabled
trac.web.auth.loginmodule = disabled
httpauth.* = enabled
acct_mgr.admin.* = enabled
acct_mgr.api.* = enabled
acct_mgr.db.sessionstore = enabled
acct_mgr.htfile.htdigeststore = disabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.http.httpauthstore = disabled
acct_mgr.notification.* = enabled
acct_mgr.pwhash.htdigesthashmethod = disabled
acct_mgr.pwhash.htpasswdhashmethod = disabled
acct_mgr.register.* = disabled
acct_mgr.svnserve.* = enabled
acct_mgr.svnserve.svnservepasswordstore = disabled
acct_mgr.web_ui.* = enabled

[account-manager]
password_store = HtPasswdStore
htpasswd_hash_type = md5
htpasswd_file = /opt/trac/.htpasswd

[httpauth]
paths = /login, /xmlrpc, /login/xmlrpc

用admin用户登录后http://trac.folowing.com/admin/general/perm,进行初始化设置

http://trac.folowing.com/admin 设置Basic Settings,time zone等

http://trac.folowing.com/admin/general/perm 设置权限,把anonymous和autheticate的权限全部删去,创建developer权限,

developer   REPORT_VIEW TICKET_CREATE TICKET_VIEW XML_RPC 
tester      REPORT_VIEW TICKET_CREATE TICKET_MODIFY TICKET_VIEW

注意问题

  • TracAccountManager版本必须是0.4,不然会有warning。
  • Mylyn版本必须是mylyn-3.7.1.v20120425-0100

参考:

  • http://apt-blog.net/trac-on-uwsgi-and-nginx-simple-steps
  • http://trac-hacks.org/wiki/XmlRpcPlugin
  • http://trac-hacks.org/wiki/HttpAuthPlugin
  • http://trac-hacks.org/wiki/CookBook/AccountManagerPluginConfiguration