ubuntu14.04上Trac配置记录
系统环境:ubuntu14.04 (并假设Apache2服务可以正常运行)
1. 安装软件:
sudo aptitude install trac python-mysqldb
2. 创建数据库
Trac可支持的数据库有:sqlite, postgresql及mysql等。默认的是sqlite,但这里选用的是mysql。
$ mysql -uroot -p
Enter password: ******
mysql> CREATE DATABASE $myproject DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
mysql> show databases;
mysql> exit
说明:Trac可以管理很多个项目,所以每个项目都需要创建自己的数据库。
3. 创建Trac环境的根目录
sudo mkdir /var/www/trac
因为Trac是需要与Apache2服务绑定的,所以一般放到/var/www下,当然了用户也可根据喜好随意设置位置。
4. 创建Trac项目
cd /var/www/trac
sudo mkdir test
sudo trac-admin test initenv
>>projectname: test
>>conn database: mysql://root:******@localhost/test
说明:数据库名称,项目名称最好都保持一致,免得容易混淆。这里的“Test” 即前面的 $myproject。
然后更改权限:
sudo chown -R www-data:www-data trac
sudo chmod -R g+rsw trac
5. 绑定Apache2服务
编辑配置文件:/etc/apache2/apache2.conf,在文件最后添加如下内容:
<Location "/trac">
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/www/trac
PythonOption TracUriRoot /trac
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/.svn_and_trac.htpasswd
Require valid-user
</Location>
认证方式为“Basic”,密码文件位置/etc/apache2/.svn_and_trac.htpasswd
上面配置也可以写成:
<Location "/trac">
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/www/trac
PythonOption TracUriRoot /trac
</Location>
<LocationMatch "/trac/[^/]+/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/.svn_and_trac.htpasswd
Require valid-user
</LocationMatch>
跟上面的区别是,第一种配置为强制登录认证,不允许匿名访问;第二种则不强制。
确认以下模块(都在/etc/apache2/mods-enabled目录下)都已经启动起来,可通过以下命令确认:
sudo a2enmod env
sudo a2enmod auth_basic
sudo a2enmod python
6. 创建密码文件
Apache2认证的方式按照级别递增的顺序可分为:Basic, Digest, SSL; 前两种是通过http方式访问的,SSL是通过https,配置稍复杂。
这里使用的Basic认证:
$ htpasswd -c /etc/apache2/.svn_and_trac.htpasswd $username
参数“-c”表示第一次创建密码文件。如果后续需要追加用户,就不可使用参数“-c”了。如果将命令htpasswd替换成命令htdigest,则创建就是Digest认证文件了。
补充说明一下下面的几个命令:
* a2dismod ------> disable一个Apache2模块,即从mods-enabled/目录中删除该模块的链接
* a2dissite ------> disable一个Apache2配置,即从sites-enabled/目录中删除该配置的链接
* a2enmod ------> enable一个Apache2模块,即在mods-enabled/目录中创建一个到mods-available/的模块的链接
* a2ensite ------> enable一个Apache2配置,即在sites-enabled/目录中创建一个到sites-available/的配置的链接
说明:在/etc/apache2的配置文件目录下一般有如下目录:
* mods-available/ ------> 所有已安装的Apache2模块
* mods-enabled/ ------> 已经被开启正被使用的Apache2模块,都是链接到mods-available/的链接文件
* sites-available/ ------> 所有可支持的Apache2启动配置文件
* sites-enabled/ ------> 默认被使用的Apache2启动配置文件,都是链接到sites-available/的链接文件
7. 更改Trac环境的logo
编辑文件trac/$myproject/conf/trac.ini,相应部分更改如下:
[header_logo]
alt = (logo of ucrobotics)
height = -
link = http://www.ucrobotics.com
src = /themes/garamond/img/header-icon.gif
width = -
8. 添加管理权限
sudo trac-admin /var/www/trac/test permission add $username TRAC_ADMIN
对于具有管理权限的用户,在通过浏览器访问Trac环境的时候,其导航栏的最右边会有一个“Admin”的链接,进入之后可以对其它用户的权限进行配置。
一般来说,具有管理权限的用户可以通过Web界面进行管理操作了,但若是需要通过命令行进行操作,可参考:wiki:TracAdmin
9. 重启Apache2服务测试
sudo /etc/init.d/apache2 restart
测试地址:http://localhost/trac
附录一:配置Trac有两种方式:做为CGI(CGI、WSGI、FCGI)以及使用mod-python。
上面展示的是mod-python方式,如果是CGI,可通过如下命令生成CGI文件(供参考):
sudo trac-admin /var/www/trac/test deploy /tmp/deploy
sudo mv /tmp/deploy/cgi-bin /var/www
sudo mv /tmp/deploy/htdocs /var/www/htdocs.trac.bak (暂时没用到这个目录)
注意:这里将生成的CGI文件直接拷贝到/var/www下了,这样一来,以后再创建其它新的Trac环境就不需要再生成新的CGI文件了。
给这些新生成的文件一起赋予权限:
sudo chown -R www-data:www-data trac cgi-bin htdocs.trac.bak
sudo chmod -R g+rsw trac cgi-bin htdocs.trac.bak
附录二:运行过程中遇到的错误解决
错误内容如下:
ERR1: AttributeError: NullTranslationsBabel instance has no attribute 'isactive'
ERR2: AttributeError: 'NullTranslations' object has no attribute 'add'
解决方法是修改文件:/usr/share/pyshared/trac/util/translation.py,修改log如下:
$ diff -Nur translation.py.orig translation.py
--- translation.py.orig -- ::16.130643165 +
+++ translation.py -- ::42.038584449 +
@@ -, +, @@
self._activate_failed = True
return
t = Translations.load(locale_dir, locale or 'en_US')
- if not t or t.__class__ is NullTranslations:
+ #if not t or t.__class__ is NullTranslations:
+ if not isinstance(t, Translations):
t = self._null_translations
else:
t.add(Translations.load(locale_dir, locale or 'en_US',
@@ -, +, @@ @property
def isactive(self):
- if self._current.args is not None:
- get_locale, env_path = self._current.args
- self._current.args = None
- self.activate(get_locale(), env_path)
- # FIXME: The following always returns True: either a translation is
- # active, or activation has failed.
- return self._current.translations is not None \
- or self._activate_failed
+ try:
+ if self._current.args is not None:
+ get_locale, env_path = self._current.args
+ self._current.args = None
+ self.activate(get_locale(), env_path)
+ # FIXME: The following always returns True: either a translation is
+ # active, or activation has failed.
+ return self._current.translations is not None \
+ or self._activate_failed
+ except AttributeError, e:
+ import sys
+ exc_info = sys.exc_info()
+ raise Exception, unicode(e), exc_info[]
+ # Delegated methods
参考:http://webplay.pro/linux/ubuntu/install-trac-1-1-2-dev-on-ubuntu-12-04.html
ubuntu14.04上Trac配置记录的更多相关文章
- 【转】Linux(ubuntu14.04)上编译Android4.4源码的环境搭建及编译全过程
原文网址:http://jileniao.net/linux-android-building.html sublime text让我伤心.本来很信任sublime text的自动保存功能,之前使用一 ...
- 菜鸟玩云计算之十六:Ubuntu14.04上创建的虚拟机迁移到RHEL6.4
菜鸟玩云计算之十六:Ubuntu14.04上创建的RHEL6.4虚拟机迁移到RHEL6.4主机上 RHEL6.4 Server作为虚拟机的HOST,执行以下的命令检查配置和安装相关软件: # egre ...
- ubuntu14.04上实现faster rcnn_TF的demo程序及训练过程
安装环境:Ubuntu14.04.显卡Tesla K40C+GeForce GT 705.tensorflow1.0.0.pycharm5.0 说明:原文见博客园,有问题原文下留言,不定期回复.本文作 ...
- 在ubuntu14.04上搭建OpenVPN服务
简介 在连接了不可信的网络环境后,让手机或者计算机安全的访问互联网,使用虚拟专用网络(Virtual Private Network,VPN)是一个解决办法.OpenVPN是一个SSL VPN完整解决 ...
- Ubuntu14.04上深度学习Caffe库安装指南(CUDA7.5 + opencv3.1)
Ubuntu14.04上Caffe安装指南 安装的准备工作 首先,安装官方版Caffe时.假设要使用Cuda.须要确认自己确实有NVIDIA GPU. 安装Ubuntu时,将/boot 分区分大概20 ...
- [译]How to Install Node.js on Ubuntu 14.04 如何在ubuntu14.04上安装node.js
原文链接为 http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/ 由作者Jacob Nicholson 发表于October ...
- Ubuntu14.04上安装pip的方法
在Ubuntu14.04上,建议通过下面的方法安装,这是一种通用的方法,也适用于Windows,当然在Windows下 手动下载下来就行了 wget https://bootstrap.pypa.io ...
- Ubuntu14.04 Tomcat 安装过程记录
Ubuntu14.04 Tomcat 安装过程记录 检查java的版本 zhousp@ubuntu:~$ sudo java -version [sudo] password for zhousp: ...
- Ubuntu14.04上修改主机名
Ubuntu14.04上修改主机名 author:headsen chen 2017-10-12 15:41:31 个人原创,转载请注明作者,出处,否则依法追击法律责任 查看主机名:hostname ...
随机推荐
- C, C#, AS3的变量
高级语言中变量分值类型和引用类型, C中则分栈和堆, 在作为函数参数传递时,值类型复制,引用类型传递引用,不复制: 高级语言中一些基本类型默认是值类型, 其他基本都是引用类型. C语言中栈和堆变量可以 ...
- C#网络编程一:C#网络编程常用特性
特性一:委托 委托是C#语言中特有的概念,相当于C/C++中的函数指针,与C/C++中函数指针的不同之处是:委托是面向对象的.类型安全的和保险的,是引用类型.因此,对委托的使用要 "先定义. ...
- 获取图片工具类:BitmapUtil
package com.example.administrator.filemanager.utils;import android.content.Context;import android.gr ...
- Texture Filter中的Bilinear、Trilinear以及Anistropic Filtering
1. 为什么在纹理采样时需要texture filter(纹理过滤)?我们的纹理是要贴到三维图形表面的,而三维图形上的pixel中心和纹理上的texel中心并不一至(pixel不一定对应texture ...
- js中的原形链问题
---恢复内容开始--- 一.在js中大家讨论的原形链都是围绕在prototype和__proto__. 1.__proto__是内部原型 2.prototype是构造器原型(构造器就是构造函数) 3 ...
- html window.open 使用详解
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no ...
- ubuntu Unity Tweak Tool
Unity Tweak Tool first install main program if do not run,so,second run : sudo apt-get install unity ...
- 快速解析超大XML不占用太大内存
import xml.etree.ElementTree as ET def parse_res(xml_file): res_dic = {} tmp_lst_lev1 = [] tmp_lst_l ...
- [整理]一个有关Latch(锁存器)的有趣问题
起源 今天诳论坛,突然发现了一个有关latch的问题,由于对D Flip-Flop和Latch还有些疑问,就点击了进去,一看果然有些意思,也挺有学习意义的,于是本文就诞生了.喊出口号~Just not ...
- Java 的replace和replaceAll的使用
(1)replace() 方法通过用 newChar 字符替换字符串中出现的所有 oldChar 字符,并返回替换后的新字符串. public String replace(char oldChar, ...