1、咱先把CVS裝上吧
首先確定系統中沒有安裝CVS,如果沒有則安裝:
yum install cvs 註:fedora中可以使用光碟片安裝,個人認為容易點哦
2、確認系統中是否安裝xinetd,在Fedora 6中這個沒有預設安裝。如果沒有安裝則安裝:
yum install xinetd 註:這個我是用命令列在網上自動下載安裝的,中間還出現了個錯誤,忽略了
3、修改/etc/xinetd.d/cvs
[root@fc6 CVSROOT]# cat /etc/xinetd.d/cvs
# 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=/zyf/cvs
server_args = -f --allow-root=/zyf/cvs pserver
# bind = 127.0.0.1
}
4、初始化cvs服務
cvs -d /zyf/cvs init
註:這個路徑要和/etc/xinetd.d/cvs中的一致,並且可以隨便根據自己的需要定製.
5、增加使用者
groupadd cvs
useradd cvsroot -g cvs
6、設定目錄許可權
chmod 777 /zyf/cvs
7、修改/zyf/cvs/CVSROOT/config檔案
[root@fc6 CVSROOT]# cat config
# Set this to "no" if pserver shouldn't check system users/passwords
SystemAuth=no 註:這裡預設是注釋掉的。
# Put CVS lock files in this directory rather than directly in the repository.
#LockDir=/var/lock/cvs
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no
# Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the
# history file, or a subset as needed (ie `TMAR' logs all write operations)
#LogHistory=TOEFWUPCGMAR
# Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg
# script to change the log message. Set it to `stat' to force CVS to verify
# that the file has changed before reading it (this can take up to an extra
# second per directory being committed, so it is not recommended for large
# repositories. Set it to `never' (the previous CVS behavior) to prevent
# verifymsg scripts from changing the log message.
#RereadLogAfterVerify=always
註:這個更改是為了使用者驗證的時候忽略系統使用者,這樣可以避免建立很多的系統帳戶,而影響安全性。
8、增加/zyf/cvs/CVSROOT/passwd檔案
[root@fc6 CVSROOT]# cat passwd
zyf:woXRXXMqwnmWs:cvsroot
註:這個密碼檔案中第2段是md5的密碼。多個使用者為每行一個. 這個密碼真的不太好得到,每次都是建使用者。
9、增加/zyf/cvs/CVSROOT/readers檔案
這個檔案中儲存著所有唯讀使用者的使用者名稱,一行一個.
10、增加/zyf/cvs/CVSROOT/writers檔案
這個檔案中儲存著所有可寫入權限的使用者名稱,一行一個.
注:同一個使用者不要在/zyf/cvs/CVSROOT/readers和/shanmin/cvs/CVSROOT/writers中都填寫,如果都填寫則以/zyf/cvs/CVSROOT/readers中的為準。
11、關閉SELinux
[root@~]#setenforce 0
註:CVS和SELinux有“衝突”,必須關閉,不然用戶端會提示沒有許可權。
修改/etd/services檔案 ,加入以下內容:
cvspserver 2401/tcp # CVS client/server operations
cvspserver 2401/udp # CVS client/server operations
cvs服務由inted來喚起,因此需要改動inetd提供的服務,我的redhat使用的是inetd
方式則在檔案/etc/inetd.conf中加入如下的內容:cvspserver stream tcp nowait root
/usr/bin/cvs cvs --allow-root=/home/cvsroot pserver
FC6使用的是xinetd方式,所以在xinetd.d目錄下添加需要啟動的服務:
cd /etc/xinetd.d
vi cvspserver
檔案內容:
service cvspserver
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/bin/cvs
server_args = -f --allow-root=/home/cvsroot pserver
log_on_failure += USERID
}
12.重新啟動inetd或者xinetd:
/etc/rc.d/init.d/xinetd restart
13.檢查cvspserver服務是否已經啟動
netstat -l |grep cvspserver
結果如下:
tcp 0 0 *:cvspserver *:* LISTEN
以上結果全部通過,但是在客戶機上執行
cvs -d :pserver:steven@192.168.211.72:/home/cvsroot login
輸入密碼後,沒有收到任何訊息,即表示成功
^_^ no news is a good news!!
在用戶端,設定環境變數如下:
export CVS_RSH=ssh
export CVSROOT=:pserver:username@ip:/home/cvsroot
你可以
echo $CVS_RSH
ssh
echo $CVSROOT
:pserver:username@ip:/home/cvsroot
這樣你在用戶端就可以直接輸入 cvs login登陸了
其它操作都可以直接cvs command 了
12、啟動服務
service xinetd start
13、防火牆開2401連接埠 註:我是把防火牆關了。
還要注意:writers一定要設定好許可權,為了這個頗費了一陣子勁兒。