下面由Centos入門教學欄位介紹centos上建立SVN並將專案同步到PHP專案的系統根目錄的方法,希望對需要的朋友有所幫助!
一、SVN安裝
這裡採用yum安裝方式:
1、rpm -qa subversion / /檢查是否安裝了低版本的SVN
2、yum remove subversion //如果儲存舊版本,卸載舊版SVN
3、開始安裝yum -y install subversion
##安裝好後查看版本svnserve --version 4、建立版本倉庫:mkdir -p /data/svn/project svnadmin create /data/svn/project/查看/data/svn/project 資料夾可以發現有conf, db,format,hooks, locks, README.txt等文件,說明一個SVN函式庫已經建立。 5、設定權限
cd /data/svn/project/conf/ //进入配置目录 vim svnserve.conf //编辑配置文件,加入下面五行内容 ``` [general] ### The anon-access and auth-access options control access to the`` ### repository for unauthenticated (a.k.a. anonymous) users and ### authenticated users, respectively. ### Valid values are "write", "read", and "none". ### Setting the value to "none" prohibits both reading and writing; ### "read" allows read-only access, and "write" allows complete ### read/write access to the repository. ### The sample settings below are the defaults and specify that anonymous ### users have read-only access to the repository, while authenticated ### users have read and write access to the repository. # anon-access = read # auth-access = write anon-access = none auth-access = write password-db = passwd authz-db = authz realm = /data/svn/project ```6、編輯密碼檔案,新增使用者test 密碼123456:
vim passwd ### This file is an example password file for svnserve. ### Its format is similar to that of svnserve.conf. As shown in the ### example below it contains one section labelled [users]. ### The name and password for each user follow, one account per line. [users] # harry = harryssecret # sally = sallyssecret test = 1234567、編輯權限文件,新增使用者test權限
vim authz [groups] # harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe [/] test = rw8、設定防火牆
vi /etc/sysconfig/iptables加入:
``` -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 3690 -j ACCEPT ```重啟防火牆:service iptables restart 9、啟動SVN:svnserve -d -r/data/svnv 查看連接埠狀態:netstat -ln | grep 3690
二、為svn新增鉤子同步檔案到PHP測試環境(這裡PHP專案目錄為/ var/www/html/project/)
1、進入版本庫下的hooks目錄cd /data/svn/project/hooks/2、將post-commit.tmpl 複製為post-commit
cp post-commit.tmpl post-commit3、給post-commit可執行權限
chmod 0777 post-commit4、編輯post-commit,註解掉#mailer.py......這一行,新增下面四行,編碼問題,如果錯誤的話可能導致無法同步 成功,可選的有en_US.UTF-8、zh_CN.UTF-8、zh_CN.GB2312,可以一個個試。
vi post-commit #mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf export.GB2312 SVN=/usr/bin/svn STATIC_DIR=/var/www/html/project/ ${SVN} update ${STATIC_DIR} --username "test" --password "123456"5、在提交之前,進行一次checkout代碼到指定目錄
svn checkout svn://localhost/project /var/www/html/project/註:如果一直出錯:「由於連接方在一段時間後沒有正確答复或連接的主機沒有反應,連線嘗試失敗」;可能是網路埠開放設定問題,因為連接埠問題導致無法成功checkout項目,可以進入阿里雲看看看看有沒有允許3690的端口,如果沒有3690的端口就添加一條安全組規則。 更多centos技術文章,請當
以上是centos上建置SVN並將專案同步到PHP專案的系統根目錄的方法詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!