centos下安裝CVS及配置

Centos 中安裝CVS Server方法

用過一段時間cvs,后来用SVN,現在都沒有印像了,故温习一下

 一、系统上是否已经安装相关的服务

1、cvs的安装
查看CVS的安装情况 写道
[qinshiqi@localhost Desktop]$ rpm -qa |grep cvs
lklug-fonts-0.6-4.20090803cvs.el6.noarch
libedit-2.11-4.20080712cvs.1.el6.x86_64
xdg-utils-1.0.2-17.20091016cvs.el6.noarch
 [qinshiqi@localhost Desktop]$ rpm -q xinetd
package xinetd is not installed
[qinshiqi@localhost Desktop]$ rpm -q cvs
package cvs is not installed
如果没有安装 ,则可用 yum install cvs安装,或者下载cvs单独安装
CVS下载地址,没有试过
http://download.chinaunix.net/download/0001000/76.shtml
 但通过yum安装 的时候有问题请参考如何修改yum源以解决问题
http://qinshiqi.iteye.com/admin/blogs/2036014

然后在通过yum

[root@localhost yum.repos.d]# yum install cvs
Loaded plugins: fastestmirror, refresh-packagekit, security
……………………………………。

Installed:
  cvs.x86_64 0:1.11.23-16.el6                                                  

Complete!

验证cvs是否已经安装上了:
[root@localhost yum.repos.d]# rpm -qa cvs
cvs-1.11.23-16.el6.x86_64

参数|grep cvs与 cvs的区别:

[root@localhost Documents]# rpm  -qa |grep cvs
lklug-fonts-0.6-4.20090803cvs.el6.noarch
libedit-2.11-4.20080712cvs.1.el6.x86_64
xdg-utils-1.0.2-17.20091016cvs.el6.noarch
cvs-1.11.23-16.el6.x86_64
[root@localhost Documents]# rpm  -qa cvs
cvs-1.11.23-16.el6.x86_64

2、xinetd服务是否已经安装,如果没有安装,先安装上

  

这个通过yum安装还是失败,干脆直接从安装盘上拷贝过来安装吧

[root@localhost ShareForVM]# rpm -ivh xinetd-2.3.14-38.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:xinetd                 ########################################### [100%]
[root@localhost ShareForVM]# rpm -qa xin
[root@localhost ShareForVM]# rpm -qa xinetd
xinetd-2.3.14-38.el6.x86_64

3,修改环境变量(目前不是必须的)

$su root

#vi /etc/profile

在最后添加

CVSROOT=/home/cvsroot

exprot CVSROOT

保存后,

#source /etc/profile

成功后,检查环境变量添加是否成功

#echo $CVSROOT


二、CVS的配置

     

  1、设置用户

    

设置CVS用户 写道
创建用户组cvsg
[root@localhost Documents]# groupadd cvsg
在这个组下增加用户cvsroot
[root@localhost Documents]# useradd cvsroot -g cvsg
修改新加用户的密码c*_testr*_
[root@localhost Documents]# passwd cvsroot
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

     2、建立CVS仓库并初始化

[root@localhost cvsroot]# pwd
/home/cvsroot
改变/home/cvsroot的目录属性
chmod 775 /home/cvsroot(/home/cvsroot目录需要至少给群组权限)

建立仓库 写道
[root@localhost cvsroot]# chmod 775 /home/cvsroot
[root@localhost cvsroot]# cvs -d /home/cvsroot init
[root@localhost cvsroot]# ls
CVSROOT
[root@localhost cvsroot]# cd CVSROOT/
[root@localhost CVSROOT]# ls
checkoutlist config,v Emptydir modules,v taginfo
checkoutlist,v cvswrappers history notify taginfo,v
commitinfo cvswrappers,v loginfo notify,v val-tags
commitinfo,v editinfo loginfo,v rcsinfo verifymsg
config editinfo,v modules rcsinfo,v verifymsg,v

 3、创建登录cvs服务的用户以及密码

[root@localhost CVSROOT]# htpasswd -c passwd yfeifei
New password:
Re-type new password:
Adding password for user yfeifei
d*_****
在/home/cvsroot/CVSROOT下运行htpasswd -c passwd yfeifei
(-c 会生成passwd文件,以后再创建用户就不需要 -c 参数了,可以使用 -n 参数直接指定用户名,但要在passwd文件中添加对应的用户名称加密密码以及:cvsroot)

(创建的feifei用户是以其所在群组为cvs的资格来可读可写可执行仓库中的文件)

修改passwd文件,在用户名后边加上cvsroot

*************************

[root@localhost CVSROOT]# htpasswd  passwd qin
New password:
Re-type new password:
Adding password for user qin
[root@localhost CVSROOT]# cat passwd
yfeifei:7vV7AcR3pOORk:cvsroot
qishi:v8yvvdpJ71L7w:cvsroot
qin:9tTPnujUuKP82
[root@localhost CVSROOT]# 

注意
qin后边必须加:cvsroot,

加这个的使用是CentOS系统将cvs用户与系统用户对应
 

4、检查服务是否配置

root@localhost ShareForVM]# more /etc/services |grep cvspserver
cvspserver      2401/tcp                        # CVS client/server operations
cvspserver      2401/udp                        # CVS client/server operations

如果出现以上结果,说明配置成功,否则需要手动添加(vi /etc/services)

这两行在cvs服务安装完成时就会存在,如果没有可以手动添加,我们可以清楚看到cvs服务的监听端口是默认的2401。

修改cvspserver的监听端口,将2401改成与系统其他端口不冲突,自己喜欢的端口号就可以了。

修改方式 写道
.修改cvs服务监听端口
# vi /etc/services
修改cvspserver的监听端口,将2401改成与系统其他端口不冲突,自己喜欢的端口号就可以了。

重启xinetd服务
# service xinetd restart
 

5修改cvs文件

 Linux的其他版本可能是cvspserver,没有时需要手动创建该文件,在我安装的centos6.3中,没有这个文件,网上说centos6默认应该是有的,不知为什么,先创建吧

/etc/xinetd.d/cvs

/etc/xinetd.d/cvspserver 

# default: off
# description: The CVS service can record the history of your source \
#              files. CVS stores all the versions of a file in a single \
#              file in a clever way that only stores the differences \
#              between versions.
service cvspserver
{
        disable                 = no
        port                    = 2401
        socket_type             = stream
        protocol                = tcp
        wait                    = no
        user                    = root
        passenv                 = PATH
        server                  = /usr/bin/cvs
      #  env                     = HOME=/var/cvs

       env                     = HOME=/home/cvsroot
       # server_args             = -f --allow-root=/var/cvs pserver

       server_args             = -f --allow-root=/home/cvsroot pserver
#       bind                    = 127.0.0.1
}

6.重启xinetd服务
#service xinetd restart

7、检查cvspserver服务是否已经启动:

[root@localhost xinetd.d]# netstat -l|grep cvspserver
tcp        0      0 *:cvspserver                *:*                         LISTEN     [root@localhost xinetd.d]# netstat -lnp|grep 2401
tcp        0      0 :::2401                     :::*                        LISTEN      6804/xinetd        
 
8、客户端连接检查

[root@localhost Documents]# cvs -d:pserver:[email protected]:/home/cvsroot login
Logging in to :pserver:[email protected]:2401/home/cvsroot
CVS password:
cvs [login aborted]: unrecognized auth response from 172.28.146.116: cvs pserver: cannot open /home/cvsroot/CVSROOT/config: Permission denied

不知什么原因,所以先对这个目录授权/home/cvsroot

[root@localhost Documents]# chmod 755 -R /home/cvsroot
[root@localhost Documents]# chown cvsroot:cvsg -R /home/cvsroot

授权后也还是不行,出现一面的信息
[root@localhost Documents]# cvs -d:pserver:[email protected]:/home/cvsroot login
Logging in to :pserver:[email protected]:2401/home/cvsroot
CVS password:
cvs [login aborted]: unrecognized auth response from XXX.28.146.116: cvs pserver: cannot open /home/cvsroot/CVSROOT/config: Permission denied

关于CVS中出现cannot open /cvsroot/xxx/CVSROOT/config: Permission denied的问题

 

RedHat linux中有一个叫selinux的东西,它倒置了CVS读不到config文件,如果出现问题了就把selinux关了就好了..(个人感觉应该像是进程防火墙的意思,有机会再详细研究下,实际上关了好像不太好..)..

关闭的方法: 

#setenforce 0   

这个每次机器重启后都需要在执行一下,否则又出现上面的问题

SElinux以及防火墙的关闭

关闭SELinux的方法:
  修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
  如果不想重启系统,使用命令setenforce 0
注:
setenforce 1 设置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式
  在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux

A不重启设置# setenforce 0
重启后失效
B 需要重启Linux:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled
写道
[root@localhost /]# getenforce
Permissive
[root@localhost /]# setenforce 0
[root@localhost /]# getenforce
Permissive
[root@localhost /]# setenforce 1
[root@localhost /]# getenforce
Enforcing
 
[root@localhost /]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 
 
把SELINUX=enforce   改成disabled就可以了,重启电脑,永久生效

[root@localhost CVSROOT]# cvs -d:pserver:[email protected]:/home/cvsroot login
Logging in to :pserver:[email protected]:2401/home/cvsroot
CVS password:
[root@localhost CVSROOT]#

三、centos防火墙

查看运行的状态

[root@localhost CVSROOT]# /etc/init.d/iptables status
iptables: Firewall is not running.
[root@localhost CVSROOT]# service iptables status
iptables: Firewall is not running.
[root@localhost CVSROOT]# /etc/init.d/iptables status
iptables: Firewall is not running.
[root@localhost CVSROOT]# /etc/init.d/iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@localhost CVSROOT]# /etc/init.d/iptables status
Table: filter
……………………
[root@localhost CVSROOT]# /etc/init.d/iptables stop

3、 打开iptables的配置文件直接修改,这个永久有效:
vi /etc/sysconfig/iptables

直接安装22端口的设置复制一行,呵呵

   1、这个不起使用呀

     [root@localhost CVSROOT]# chkconfig iptables
[root@localhost CVSROOT]# chkconfig iptables  on
[root@localhost CVSROOT]# service iptables status
iptables: Firewall is not running.

   2、  即时生效,重启后失效:

  开启: service iptables start

  关闭: service iptables stop

     这个起作用,


     需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。

  在开启了防火墙时,做如下设置,开启相关端口,

  修改/etc/sysconfig/iptables 文件,添加以下内容:

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

      

       -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
       -A INPUT -p tcp -m state --state NEW -m tcp --dport 2401 -j ACCEPT

  或者:

  /etc/init.d/iptables status 会得到一系列信息,说明防火墙开着。

  /etc/rc.d/init.d/iptables stop 关闭防火墙

   
建议的关闭防火墙命令是

  iptables -P INPUT ACCEPT

  iptables -P FORWARD ACCEPT

  iptables -P OUTPUT ACCEPT

  iptables -F

3、 打开iptables的配置文件直接修改,这个永久有效:
vi /etc/sysconfig/iptables

直接安装22端口的设置复制一行,呵呵

然后#service iptables restart

写道
手工配置,感觉这个没有起作用
或者我们可以在CentOS操作系统使用命令:
#/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
#sbin/iptables -I INPUT -p tcp –dport 22 -j ACCEPT3
#etc/init.d/iptables save
测试这个不行,
 
写道
这两个目录
/sbin/iptables
/etc/init.d/iptables
[root@localhost sbin]# /etc/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost sbin]# /etc/init.d/iptables start
iptables: Applying firewall rules: [ OK ]

[root@localhost sbin]# service iptables start
[root@localhost sbin]# service iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost sbin]# service iptables start
iptables: Applying firewall rules: [ OK ]
 
 
永久关闭防火墙 写道
永久关闭防火墙

我们也可以永久的关闭防火墙,但是我不建议大家这样做.永久关闭防火墙可以这样:
#chkconfig –level 35 iptables off
也可以直接修改
/etc/sysconfig/iptables
添加一条
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

这样,我们就介绍完了如何CentOS操作系统防火墙配置及关闭步骤.
 
 进一步了解CVS平台的使用 http://www.kuqin.com/cvsdocument/index.html#toc_Repository  参考: http://hi.baidu.com/xizenyin/item/ab91aa21fdcc47112a0f1c05 http://blog.chinaunix.net/uid-20640366-id-1908902.html  http://blog.sina.com.cn/s/blog_6d0d1c2c0100y20y.html  http://www.doc88.com/p-971854762034.html http://blog.sina.com.cn/s/blog_537a7ce301000awy.html

猜你喜欢

转载自qinshiqi.iteye.com/blog/2035529