Ubuntu 源码方式安装Subversion
使用到的安装包:
apr-1.5.1.tar.gz apr-util-1.5.3.tar.gz pcre-8.35.tar.gz httpd-2.4.9.tar.bz2 subversion-1.8.9.tar.bz2 zlib-1.2.8.tar.gz
scons-2.3.1.tar.gz
serf-1.3.5.tar.bz2
sqlite-amalgamation-3080403.zip
openssl-1.0.1g.tar.gz
解压缩命令:
tar zxvf ***.tar.gz tar jxvf ***.tar.bz2
unzip ***.zip
1.先安装apr
cd apr-1.5.1 ./configure --prefix=/usr/local/apr make sudo make install
2.安装apr-util
cd apr-util-1.5.3 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make sudo make install
3.安装pcre
cd pcre-8.35 ./configure --prefix=/usr/local/pcre make make install
(安装pcre报错configure: error: You need a C++ compiler for C++ support)
sudo apt-get install build-essential (Ubuntu默认并不提供C/C++的编译环境)或者: yum install -y gcc gcc-c++
4.安装openssl
cd openssl-1.0.1g ./config -fPIC --prefix=/usr/local/openssl/ enable-shared make sudo make install
PIC就是position independent code,它的作用是代码共享,如果不加-fPIC,则加载.so文件的代码段时,代码段引用的数据对象需要重定位, 重定位会修改代码段的内容,这就造成每个使用这个.so文件代码段的进程在内核里都会生成这个.so文件代码段的copy.
5.安装httpd
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-openssl=/usr/local/openssl --with-ssl make make install
6.启动httpd
sudo /usr/local/apache/bin/apachectl start (stop|restart)
启动httpd报错:AH00558: httpd: Could not reliably determine the server's fully qualified domain name sudo vi /usr/local/apache/conf/httpd.conf 找到#ServerName new.host.name:80,去掉前面的#,重启Apache
7.安装zlib-1.2.8
cd zlib-1.2.8/ ./configure --prefix=/usr/local/zlib make sudo make install
8.安装serf
cd scons-2.3.1 sudo python setup.py install sudo ln -s /usr/local/bin/scons /usr/bin scons --version
cd serf-1.3.5 scons PREFIX=/usr/local/serf APR=/usr/local/apr APU=/usr/local/apr-util OPENSSL=/usr/local/openssl sudo scons install
配置scons的时候报错:zlib.h: No such file or directory
sudo cp /usr/local/zlib/include/zlib.h /usr/local/include
sudo cp /usr/local/zlib/include/zconf.h /usr/local/include
9.安装svn
cp -r sqlite-amalgamation-3080403 subversion-1.8.9/sqlite-amalgamation
cd subversion-1.8.9/ ./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-zlib=/usr/local/zlib --with-apxs=/usr/local/apache/bin/apxs --enable-maintainer-mode --with-openssl=/usr/local/openssl --with-serf=/usr/local/serf make sudo make install
报错:configure: error: Subversion requires SQLite 在http://www.sqlite.org官网下载最新版的sqlite-amalgamation.zip,解压缩到subversion-1.8.9目录下新建的sqlite-amalgamation文件夹
报错:libexpat.so.1: cannot open shared object file: No such file or directory
链接库文件没有找到的问题
sudo /etc/ld.so.conf
最后另起一行,添加该共享库的绝对路径
/usr/local/serf/lib
sudo ldconfig
10.创建配置库根目录并赋权:
sudo adduser apache sudo mkdir /usr/svn_root sudo mkdir /usr/svn_root/config sudo mkdir /usr/svn_root/repository sudo chmod -R 770 /usr/svn_root/ sudo chown -R apache:apache /usr/svn_root/
11.配置apache的httpd文件(整合svn和apache)
sudo cp /usr/local/svn/libexec/mod_dav_svn.so /usr/local/apache/modules/ sudo cp /usr/local/svn/libexec/mod_authz_svn.so /usr/local/apache/modules/ sudo vi /usr/local/apache/conf/httpd.conf
a修改User和Group为apache账号启动 User apache Group apache b: 把下面两个行前面的#号去掉,注意行前不能有空格: LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so c: 在模块加载的最后添加下面两句: LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so d: 在配置文件最末尾添加: <Location /svn> DAV svn SVNListParentPath on SVNParentPath "/usr/svn_root/repository" AuthType Basic AuthName "Subversion repositories" AuthUserFile "/usr/svn_root/config/passwd.conf" AuthzSVNAccessFile "/usr/svn_root/config/authz.conf" Require valid-user </Location>
注释: SVNParentPath------------------SVN的库根目录路径,可以在这下面创建多个版本库; AuthUserFile-------------------用户帐号信息文件; AuthzSVNAccessFile-------------权限控制文件
12.创建代码库,并增加svn用户,赋予权限(切换到apache账户)
su apache 创建代码库repo1 /usr/local/svn/bin/svnadmin create /usr/svn_root/repository/repo1 创建svn用户,第一次增加需要加-c参数(创建新的passwd.conf文件) /usr/local/apache/bin/htpasswd -c /usr/svn_root/config/passwd.conf wwl New password: Re-type new password: Adding password for user wwl /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf test1 /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf test2 /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf test3
vi /usr/svn_root/config/authz.conf
[groups] admin = wwl CM = test1 test = test3,test2 [/] * = @admin = rw @CM = r [repo1:/] * = @CM = rw @test = r [repo1:/branches] @test = rw [repo1:/trunk] test2 = rw
[groups]代表组定义:“组名 = 用户1,用户2...”; [repo1:/]代表repo1配置库,repo1是配置库名称; [repo1:/trunk]代表repo1配置库下/trunk目录; @ 符号,则表示这是个群组权限设置; @ admin = rw代表admin 这个组的所有用户有读写权限 test2 = rw代表test2这个用户对trunk有读写权限 PS:注意svn的权限继承关系
13.重启apache:
增加repo1代码库里面文件并上传后,重启apache会看到:
sudo /usr/local/apache/bin/apachectl restart
题外话:
每次输svn、apache命令都要写绝对地址好烦,ln是你的好帮手
sudo ln -s /usr/local/svn/bin/* /usr/bin
sudo ln -s /usr/local/apache/bin/* /usr/bin
使用svn涉及到http路径的话 例如:svn checkout http://192.168.186.144/svn/repo1
报错svn: E170000: Unrecognized URL scheme for ${url}
原因:从Subversion-1.8开始需要使用serf软件包支持访问http协议的版本库
解决方法:安装serf https://code.google.com/p/serf/
安装serf1.3.x需要先安装scons http://www.scons.org/
svn1.8.x需要serf1.2.1和以上的版本:
serf1.2.1使用make方式安装
serf1.3.x使用scons方式安装
任君选择
如果不安装serf,本机器作为客户端使用svn命令行涉及http路径会有问题,但是不妨碍其作为服务器端对外提供服务。
Yesterday you say tomorrow...