安裝apache
$ sudo apt-get install apache2
安裝完成後,在瀏覽器輸入http://localhost,如果看到It works!,表示apache安裝成功。或是透過curl指令來測試apache是否安裝成功,如下:
$ sudo apt-get install curl $ curl http://localhost <html><body><h1>It works!</h1></body></html>
安裝subversion
$ sudo apt-get install subversion
svn與apache搭配使用要安裝libapache2-svn套件
$ sudo apt-get install libapache2-svn
Enable SSL
$ sudo a2enmod ssl $ sudo vim /etc/apache2/ports.conf
檢查下面內容是否存在ports.conf,如果沒有,新增下面內容:
<IfModule mod_ssl.c> Listen 443 </IfModule>
產生SSL certificate
$ sudo apt-get install ssl-cert $ sudo mkdir /etc/apache2/ssl $ sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
建立virtual host
$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl-svn-server $ sudo vim /etc/apache2/sites-available/ssl-svn-server
修改ssl-svn-server,將<VirtualHost *>改為<VirtualHost *:443>,且新增下面的內容,且插入在</VirtualHost>前面:
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem SSLProtocol all SSLCipherSuite HIGH:MEDIUM
Enable the ssl-svn-server site
$ sudo a2ensite ssl-svn-server $ sudo /etc/init.d/apache2 restart
新增一個或多個repository
$ sudo mkdir /var/svn $ sudo svnadmin create /var/svn/project1 $ sudo chown -R www-data:www-data /var/svn/project1 $ sudo chmod -R g+ws /var/svn/project1 $ sudo svnadmin create /var/svn/project2 $ sudo chown -R www-data:www-data /var/svn/project2 $ sudo chmod -R g+ws /var/svn/project2
新增使用者
$ sudo htpasswd -c -m /etc/apache2/dav_svn.passwd renee
Enable且配置WebDAV與SVN
$ sudo vim /etc/apache2/mods-available/dav_svn.conf
新增或uncomment下面內容:
<location /svn> DAV svn SVNParentPath /var/svn SVNListparentPath on AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/apache2/dav_svn.passwd <IfModule mod_authz_svn.c> AuthzSVNAccessFile /etc/apache2/dav_svn.authz </IfModule> Require valid-user SSLRequireSSL </location>
重新啟動apache
$ sudo /etc/init.d/apache2 restart
驗證,在瀏灠器輸入底下網址,會看到"Revision 0: /",表示成功
https://localhost/svn/project1
svn存取方法
import test_file檔案或test_folder資料夾下所有檔案到repository
Schema | Access Method |
---|---|
file:// | direct repository access (on local disk) |
http:// | Access via WebDAV protocol to Subversion-aware Apache2 web server |
https:// | Same as http://, but with SSL encryption |
svn:// | Access via custom protocol to an svnserve server |
svn+ssh:// | Same as svn://, but through an SSH tunnel |
import test_file檔案或test_folder資料夾下所有檔案到repository
$ svn import --username renee test_file https://localhost/svn/project1/test_file $ svn import --username renee test_folder https://localhost/svn/project1
資料checkout回來
$ svn co --username renee https://localhost/svn/project1 /home/renee/project1
權限控制
$ vim /etc/apache2/dav_svn.authz
新增下面內容:
# 新增使用者群組 [group] admin = renee proj1_rd = tom, jack proj2_rd = mike, bob pm = monster docs_ed = mary, kate # 所有repositories的權限控制 [/] * = r #其它使用者擁有r權限 @admin = rw #admin群組擁有rw權限 # project1 repository的權限控制 [project1:/] * = r #其它使用者擁有r權限 @admin = rw #admin群組擁有rw權限 @proj1_rd = rw #proj1_rd群組擁有rw權限 @pm = r #pm群組擁有r權限 # project2 repository的權限控制 [project2:/] * = r @admin = rw @proj2_rd = rw @pm = r # project1 repository子項目的權限控制 [project1:/docs] * = r @docs_ed = rw # project2 repository子項目的權限控制 [project2:/docs] * = r mary = rw
沒有留言:
張貼留言