Centos 中安裝CVS Server方法
用過一段時間cvs,后来用SVN,現在都沒有印像了,故温习一下
一、系统上是否已经安装相关的服务
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
package xinetd is not installed
[qinshiqi@localhost Desktop]$ rpm -q cvs
package cvs is not installed
http://download.chinaunix.net/download/0001000/76.shtml
然后在通过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、设置用户
[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]# 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]#
加这个的使用是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改成与系统其他端口不冲突,自己喜欢的端口号就可以了。
# 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 cvspservertcp 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
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
重启后失效
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled
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 statusiptables: Firewall is not running.
iptables: Firewall is not running.
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
……………………
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操作系统防火墙配置及关闭步骤.