CentOS 7 源碼包安裝SVN及使用
一、準備工作
將源碼包上傳到服務器, 我這邊使用的WinSCP.
subversion-1.6.1.tar.gz
subversion-deps-1.6.1.tar.gz
// 安裝依賴包
yum install -y gcc openssl openssl-devel expat
二、安裝
// 先解壓兩個源碼包
tar -zxvf subversion-1.6.1.tar.gz
tar -zxvf subversion-deps-1.6.1.tar.gz
// 進入目錄, 先進行編譯, 不指定路徑,看有沒有報錯.
cd /lnmp/subversion-1.6.1.tar.gz
./configure
// 如果出現以下提示, 代表編譯沒有問題
// 指定路徑進行編譯安裝
./configure --prefix=/usr/local/svn/
make && make install
// 安裝成功
// 進入SVN目錄
cd /usr/local/svn
ls
// 查看SVN版本
/usr/local/svn/bin/svnserve --version
// 將SVN添加到環境變量中
vim /etc/profile
// 將下面語句添加到後面
export PATH="$PATH:/usr/local/svn/bin"
// 刷新權限
source /etc/profile
// 或者直接輸入命令將SVN添加到環境變量中
echo "export PATH=$PATH:/usr/local/svn/bin/" >> /etc/profile
source /etc/profile
三、建立一個測試倉庫
// 新建一個版本庫
mkdir -p /data/svn/svntest
svnadmin create /data/svn/svntest/
// 修改配置文件
cd /data/svn/svntest/conf
ll
vim svnserve.conf
// 將下面語句去掉註銷並修改, 保存退出
anon-access = none // 使非授權用戶無法訪問
auth-access = write // 使授權用戶有寫權限
password-db = passwd
authz-db = authz // 訪問控制文件
// 新增用戶test ,密碼123456
vim passwd
test = 123456
// 指定SVN用戶擁有的目錄權限, rw 代表讀寫權限
vim authz
// 運行SVN, 如果3690端口被占用, 後面可以加上 --listen-port 3391
svnserve -d -r /data/svn
四、 Windows鏈接
本地安裝TortoiseSVN軟件後, 右擊SVN檢出, 輸入版本庫URL,點擊確定
輸入賬號密碼, 點擊確定
完成
五、 svn鉤子(hooks)自動部署代碼到web目錄
// 切換到SVN中hooks目錄
cd /data/svn/svntest/hooks
// 復制文件
cp post-commit.tmpl post-commit
// 修改文件,添加內容, 保存退出
vim post-commit
export LANG=en_US.UTF-8
/usr/local/svn/bin/svn update /usr/local/nginx/html --username test --password 123456
// 給post-commit 加上執行權限
chmod +x post-commit
ls
svn checkout svn://ip/svntest /usr/local/nginx/html --username=test --password=123456
// 完成, 本地提交就可以了
CentOS 7 源碼包安裝SVN及使用