cvsweb安装

转载:http://www.zhuaxia.com/pre_channel/4829461/?logId=181

CVSweb就是CVS的WEB界面,可以大大提高程序员定位修改的效率:
使用的样例可以看:http://www.freebsd.org/cgi/cvsweb.cgi

 1、系统环境

操 作 系 统 :slackware 12.0
CVSweb版本 :3.0.6
Apache版本 :2.2.4(slackware 12.0默认)
说      明    :以下说明中,"#"表示超级用户运行的命令,"$"表示用户"user"运行的命令,其它表示命令内容。

 2、假定
2.1、Apache配置(slackware 12.0默认):
配置文件   :/etc/httpd/httpd.conf
DocumentRoot  : /srv/httpd/htdocs/
cgi directory : /srv/httpd/cgi/

2.2、安装用户为pub,其根目录为/home/pub/
2.3、安装CVSweb之前,要确保CVS已经安装好(安装方法可参考:http://lagvin.bokee.com/viewdiary.15620466.html

3、安装
3.1、下载CVSweb(当前最新版本是3.0.6)
$cd ~
$wget http://people.freebsd.org/~scop/cvsweb/cvsweb-3.0.6.tar.gz

3.2、解压
$tar zxvf cvsweb-3.0.6.tar.gz

3.3、把配置文件cvsweb.conf复制到apache的配置文件所在目录
$cd cvsweb-3.0.6
#cp cvsweb.conf /etc/httpd/

3.4、把cvsweb.cgi复制到apache的cgi-bin目录的cvsweb子目录下
#cd /srv/httpd/cgi-bin/
#mkdir cvsweb
#cp /home/pub/cvsweb-3.0.6/cvsweb.cgi ./cvsweb/

3.5、在DocumentRoot下创建cvsweb的目录
#mkdir /srv/httpd/htdocs/cvsweb

3.6、放置好cvsweb的icons和css目录
#cp -fr /home/pub/cvsweb-3.0.6/icons/ /srv/httpd/htdocs/cvsweb/
#cp -fr /home/pub/cvsweb-3.0.6/css/ /srv/httpd/htdocs/cvsweb/ 

4、配置
4.1、cvsweb.cgi的配置
4.1.1、设置CVS资源库
#vi /etc/httpd/cvsweb.conf
查找@CVSrepositories,找到如下段落:
#
# 'symbolic_name' => ['Name to display',  '/path/to/cvsroot']
#
@CVSrepositories = (
        'local'   => ['Local Repository', '/var/cvs'],
#       'freebsd' => ['FreeBSD',          '/var/ncvs'],
#       'openbsd' => ['OpenBSD',          '/var/ncvs'],
#       'netbsd'  => ['NetBSD',           '/var/ncvs'],
#       'ruby'    => ['Ruby',             '/var/anoncvs/ruby'],
);

其中'symbolic_name'用来标识一个CVS repository,'Name to display'部分用来显示库名,
'/path/to/cvsroot'就是实际CVS库的路径
(注意:这里说的路径,是指CVSROOT目录所在的目录。例如,我的目录是/home/cvsroot/projects/CVSROOT,则填:/home/cvsroot/projects) 

4.1.2、设置icons和css路径
查找$iconsdir,找到以下段落:
my $iconsdir = '/icons';
# format:          TEXT       ICON-URL                  width height
%ICONS = (
     back    => [('[BACK]',   "$iconsdir/back.gif",      20,   22)],
     dir     => [('[DIR]',    "$iconsdir/dir.gif",       20,   22)],
     file    => [('[TXT]',    "$iconsdir/text.gif",      20,   22)],
     binfile => [('[BIN]',    "$iconsdir/binary.gif",    20,   22)],
     graph   => [('[GRAPH]',  "$iconsdir/minigraph.png", 16,   16)],
);
undef $iconsdir;

# An URL where to find the CSS.
#
$cssurl = '/css/cvsweb.css';

修改$iconsdir和$cssurl值为:
my $iconsdir = '/cvsweb/icons';
$cssurl = '/cvsweb/css/cvsweb.css';

 

4.1.3、个性化设置
cvsweb.conf还有许多其它个性化设置,常见的有这些变量:
$logo 图标设置
$defaulttitle 标题设置
$address 管理员email地址设置
$long_intro 介绍文字
$short_instruction 说明文字

4.2、cvsweb.cgi的配置

4.2.1、指定配置文件cvsweb.cgi路径
#vi /srv/httpd/cgi-bin/cvsweb/cvsweb.cgi
查找$config,找到段落:
##### Start of Configuration Area ########

# == EDIT this ==
# Locations to search for user configuration, in order:
for (catfile($mydir, 'cvsweb.conf'), '/usr/local/etc/cvsweb/cvsweb.conf') {
  if (-r $_) {
    $config = $_;
    last;
  }
}

##### End of Configuration Area   ########

更改'/usr/local/etc/cvsweb/cvsweb.conf'部分为你的存放cvsweb.conf的实际路径,比如我的是'/etc/httpd/cvsweb.conf',则改成
for (catfile($mydir, 'cvsweb.conf'), '/etc/httpd/cvsweb.conf') {
  if (-r $_) {
    $config = $_;
    last;
  }
}

4.2.2、中文页面支持
#vi /srv/httpd/cgi-bin/cvsweb/cvsweb.cgi
查找sub html_header($;$),找到如下函数段落:
sub html_header($;$)
{
  my ($title, $moddate) = @_;
  $title  = htmlquote($title);
  my $l   = $logo || '';
  my $css = $CSS || '';
  http_header('text/html', $moddate);
  print <<EOH;
$HTML_DOCTYPE
<html>
<head>
<title>$title</title>
$HTML_META$css</head>
<body>
$l <h1>$title</h1>
EOH
}

在<head> <title>之间插入一行:<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

4.3、Apache配置

配置Aapche支持cgi
#vi /etc/httpd/httpd.conf

4.3.1、确保对cgi使用脚本别名:
ScriptAlias /cgi-bin/ "/srv/httpd/cgi-bin/"

4.3.2、确保Apache能对.cgi后缀做解释
AddHandler cgi-script .cgi

4.3.3、修改cgi-bin目录的访问权限为:
<Directory "/srv/httpd/cgi-bin">
    AllowOverride None
    Options Indexes ExecCGI -MultiViews SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

4.3.4、增加访问控制
#vi /etc/httpd/httpd.conf
添加内容:
#
# Control cvsweb accessing permission
#
<Directory "/srv/httpd/cgi-bin/cvsweb/">
    AuthName "CVS Authorization"
    AuthType Basic
    AuthUserFile /etc/httpd/cvsweb.passwd
    require valid-user
</Directory>

4.4、更改/srv/httpd/cgi-bin/cvsweb/cvsweb.cgi的访问权限
#chmod 755 /srv/httpd/cgi-bin/cvsweb/cvsweb.cgi

4.5、生成访问的帐号密码
#htpasswd -c cvsweb.paaswd <user>
如果是添加多个用户和密码到文件cvsweb.passwd,则不用-c参数 

5、错误处理:
5.1、如果发生类似
Permission denied: exec of '/srv/httpd/cgi-bin/cvsweb/cvsweb.cgi' failed
Premature end of script headers: cvsweb.cgi
的错误,则大多数是因为Apache CGI的配置和cgi权限的问题,请重看4.3 

5.2、安装cvsweb.cgi前,必须已安装File::Temp、IPC::Run、URI等3个perl模块,如果报错:
Can't locate IPC/Run.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/i486-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i486-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl) at /srv/httpd/cgi-bin/cvsweb/cvsweb.cgi line 100.
则说明IPC::Run没有安装,下载个安装则可:
$wget http://search.cpan.org/CPAN/authors/id/R/RS/RSOD/IPC-Run-0.80.tar.gz
$tar zxvf IPC-Run-0.80.tar.gz
$cd IPC-Run-0.80/
#cp -fr lib/IPC/ /usr/lib/perl5/5.8.8/i486-linux-thread-multi/

有其他错误的话,请查看apache的error.log来分析解决:
#vi /var/log/httpd/error.log

补充:配置好后,在/var/www/cgi-bin/下执行cvsweb.cgi可以正确输出结果,而用浏览器时总是报错:

Configuration not found.  Set the parameter $config in cvsweb.cgi to your cvsweb.conf configuration file first.
多方求助无效,将SELINUX停掉。又出现“Error: /: Permission denied”的错误,想来是cvsroot不让访问,于是将CVSROOT的访问权限改为775,结果大功告成!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值