1. 安装python和pip
2.安装以下软件:
pip install trac babel flup TracAccountManager
3.初始化一个trac项目:
trac-admin /path/to/project initenv
4. 创建用户
htpasswd -cm /path/to/project/user.htpasswd admin
htpasswd -m /path/to/project/user.htpasswd yc
5.赋予admin用户管理员权限
trac-admin /path/to/project permission add admin TRAC_ADMIN
6.安装nginx,配置site-enabled下的配置文件,假设为develop.conf
location / {
fastcgi_pass 127.0.0.1:9010;
# auth_basic "trac Realm";
# auth_basic_user_file /path/to/project/user.htpasswd;
#fastcgi_param AUTH_USER $remote_user;
#fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
7.配置trac.ini
增加以下行:
[account-manager]
password_store = HtPasswdStore
password_format = htpasswd
htpasswd_hash_type = md5
htpasswd_file =/path/to/project/user.htpasswd ; new style (acct_mgr >= 0.4)
reset_password = false
[components]
trac.web.auth.loginmodule = disabled
acct_mgr.admin.* = enabled
acct_mgr.api.* = enabled
acct_mgr.db.sessionstore = disabled
acct_mgr.htfile.htdigeststore = disabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.http.* = disabled
acct_mgr.notification.* = enabled
acct_mgr.pwhash.* = disabled
acct_mgr.register.* = enabled
acct_mgr.svnserve.svnservepasswordstore = disabled
acct_mgr.web_ui.* = enabled
acct_mgr.web_ui.resetpwstore = disabled
8.创建/etc/init.d/tracd.sh
#!/bin/sh
#
# Startup script for the DNS caching server
#
# chkconfig: 2345 70 30
# description: This script starts your tracd server
# processname: tracd
# pidfile: /var/run/tracd.pid
tracd --port 9010 --protocol=fcgi /path/to/project/ --user=username -d
9.启动tracd
chmod +x /etc/init.d/tracd.sh
/etc/init.d/tracd.sh
10.配置nginx
server {
listen 80;
error_log /data/user/log/nginx/trac.error.log;
access_log /data/user/log/nginx/trac.access.log;
client_max_body_size 4000m;
client_body_buffer_size 8m;
location / {
auth_basic "trac Realm";
auth_basic_user_file /path/to/project/user.htpasswd;
fastcgi_pass 127.0.0.1:9010;
#fastcgi_param AUTH_USER $remote_user;#采用TracAccountManager作为认证模块时必须注释掉。
#fastcgi_param REMOTE_USER $remote_user;
#fastcgi_param HTTPS on;#采用https时设置为on,http时注释掉
fastcgi_param SCRIPT_NAME "";
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
11.重启nginx
service nginx restart