目标:快速构建一个项目的管理系统,包括源码管理,web服务,bug追踪,工程进度,wiki
基本步骤:
1、安装Subversion
2、安装Apache
3、在Apache中配置SSL
4、在Apache中配置Subversion
5、安装trac
准备
在搭建环境之前你最好更新一下系统,确保软件是最新的可用版本
$sudo apt-get update
$sudo apt-get upgrade
1、安装Subversion
$sudo apt-get install subversion
检查一下是否安装成功,你可以用svn --version查看一下Subversion的版本信息
如果一切正常输出如下:
$svn –-version
可以看到以下输出:
svn,版本 1.6.12 (r955767)
编译于 Aug 5 2011,17:11:00版权所有 (C) 2000-2009 CollabNet。
Subversion 是开放源代码软件,请参阅 http://subversion.tigris.org/ 站点。
此产品包含由 CollabNet(http://www.Collab.Net/) 开发的软件。可使用以下的版本库访问模块:
* ra_neon : 通过 WebDAV 协议使用 neon 访问版本库的模块。
- 处理“http”方案
- 处理“https”方案
* ra_svn : 使用 svn 网络协议访问版本库的模块。 - 使用 Cyrus SASL 认证
- 处理“svn”方案
* ra_local : 访问本地磁盘的版本库模块。
- 处理“file”方案
2、安装Apache
$ sudo apt-get install apache2这个时候可以看到apache启动了!$ ps -ef | grep apache
tomcat6 6330 1 0 00:41 ? 00:00:55 /usr/lib/jvm/java-6-openjdk/bin/java -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -classpath /usr/share/tomcat6/bin/bootstrap.jar -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.io.tmpdir=/tmp/tomcat6-tmp org.apache.catalina.startup.Bootstrap start
www-data 22013 1 0 14:46 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 22016 1 0 14:46 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 22018 1 0 14:46 ? 00:00:00 /usr/sbin/apache2 -k start
lzh 24462 19693 0 14:56 pts/1 00:00:00 grep --color=auto apache$ sudo apt-get install curl检查一下是否安装成功,你可以在浏览器里面输入:http://localhost,如果正确则有一下的显示
$ curl http://localhost
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
3、在Apache中配置SSL
sudo a2enmod sslEnabling module ssl.
See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
service apache2 restart提示需要重启apache2,我们需要开启HTTPS需要的端口443,这下就需要编剧配置文件/etc/apache2/ports.conf:$ sudo vim /etc/apache2/ports.conf
[sudo] password for lzh:# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gzNameVirtualHost *:80
Listen 80<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
NameVirtualHost *:443
Listen 443
</IfModule><IfModule mod_gnutls.c>
Listen 443
</IfModule>配置好了,我们还要开启a2ensite(apache2 enable site)$ sudo a2ensite default-ssl$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName现在还是用前面那个命令测试一下:$ curl -k https://localhost如果一切正常你将看到以下输出:
<html><body><h1>It works!</h1></body></html>到这里你就有apache http,https可以用了。
4、在Apache中配置Subversion
首先你要给Apache安装Subversion module$ sudo apt-get install libapache2-svn接下来给Subversion创建Repository(debian系列svn Repository一般在/var/lib目录下,关于linux的文件系统层次结构标准你可以参照这里:http://zh.wikipedia.org/wiki/%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%B1%82%E6%AC%A1%E7%BB%93%E6%9E%84%E6%A0%87%E5%87%86):$ sudo mkdir /var/svn$ sudo mkdir /var/svn/myproject
$ sudo chown www-data:www-data /var/lib/svn/myproject
$ sudo -u www-data svnadmin create /var/lib/svn/myprojectRepository的路径已经确定了,接下来就是修改配置文件了:$ sudo vi /etc/apache2/mods-available/dav_svn.conf(有时间可以读读配置文件的说明,我觉得写得很好)添加这么一段:<Location /svn/myproject>
DAV svn
SVNPath /var/local/svn/myproject
AuthType Basic
AuthName "My Project Subversion Repository"
AuthUserFile /etc/subversion/myproject.passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>允许匿名用户(anonymous),一下配置可以禁止anonymous用户<Location /svn/myproject>
DAV svn
SVNPath /var/lib/svn/myproject
AuthType Basic
AuthName "My Project Subversion Repository"
AuthUserFile /etc/subversion/myproject.passwd
#<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
#</LimitExcept>
</Location>既然需要认证,接下来就给valid-user配置密码:默认的密码文件就是:/etc/subversion/myproject.passwd$ sudo htpasswd -c /etc/subversion/myproject.passwd xxxx(-c是创建文件,sudo 和htpasswd -h查看其用法,关于认证的一些信息你可以去查阅google)
$ sudo htpasswd /etc/subversion/myproject.passwd demo让这些配置生效:$ sudo /etc/init.d/apache2 reload用浏览器测试Apache svn服务:http://localhost/svn/myproject/
https://localhost/svn/myproject/
如果是只在命令行下,也可以用前面的curl测试:
$ curl http://username:password@localhost/svn/myproject/
<html><head><title>myproject - Revision 0: /</title></head>
<body>
<h2>myproject - Revision 0: /</h2>
<ul>
</ul>
<hr noshade><em>Powered by <a href="http://subversion.tigris.org/">Subversion</a> version 1.5.4 (r33841).</em>
</body></html>$ curl -k https://username:password@localhost/svn/myproject/
<html><head><title>myproject - Revision 0: /</title></head>
<body>
<h2>myproject - Revision 0: /</h2>
<ul>
</ul>
<hr noshade><em>Powered by <a href="http://subversion.tigris.org/">Subversion</a> version 1.5.4 (r33841).</em></body></html>你也可以用svn命令测试:$ svn co https://localhost/svn/myproject myproject --username demo$ svn mkdir -m "created the trunk for the project" https://localhost/svn/myproject/trunk --username democommit 版本1.0
5、安装trac
trac安装只要参照安装手册基本上没有任何问题:http://trac.edgewall.org/wiki/TracOnDebian
要解决本地化最好要先安装Bable
$ sudo apt-get install bable
$ sudo apt-get install trac
$ sudo apt-get install libapache2-mod-python接下来创建trac的目录:$ sudo mkdir /var/lib/trac
$ sudo chown www-data:www-data /var/lib/trac编辑apache配置文件(000-default或者是default-ssl),添加一个site$ sudo vi /etc/apache2/sites-enabled/000-default在文件的最后,</VirtualHost>之前添加一下代码:<Location /projects>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/lib/trac
PythonOption TracUriRoot /projects
PythonOption PYTHON_EGG_CACHE /tmp
</Location>
# use the following for one authorization for all projects
# (names containing "-" are not detected):
<LocationMatch "/projects/[[:alnum:]]+/login">
AuthType Basic
AuthName "trac"
AuthUserFile /etc/trac/trac.passwd
Require valid-user
</LocationMatch>接下来给trac的valid-user创建密码文件:$ sudo htpasswd -c /etc/trac/trac.passwd xxxx
$ sudo htpasswd /etc/trac/trac.passwd demo
... continue this way for all your users.创建trac要管理项目的初始化环境:$ sudo -u www-data trac-admin /var/lib/trac/myproject initenv你要输入这些信息:Project Name [My Project]> ProjectName
Database connection string [sqlite:db/trac.db]> [Just press Enter to accept the default]
Repository type [svn]> [Just press Enter to accept the default]
Path to repository [/path/to/repos]> /var/lib/svn/myproject(这里不能delete,最好是写好以后复制进去)配置完成,现在需要重启一下apache$ sudo /etc/init.d/apache2 restart把自己添加到trac这个项目的管理员里面:$ sudo -u www-data trac-admin /var/lib/trac/myproject permission add demo TRAC_ADMINdemo现在就是这个项目的管理员了,他可以通过trac提供的web管理界面来管理怎么个项目!给项目换个logo(查看手册)推荐一个logo生成网站:http://free.logomaker.cn/一个可以用的项目管理环境搭建完毕,心得:现在新的东西就是比以前的好用,比如python和trac,他们的文档都相当的全面,只要读懂文档,基本所有的都ok!我接下来要根据需要订制trac[基本的需要定制tickets,通知人的策略等,有兴趣的朋友可以联系,一起研究!