使用到的安装包:
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
解压缩命令:
tar zxvf ***.tar.gz
tar jxvf ***.tar.bz2
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.安装httpd
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
make
make install
(安装httpd报错configure: error: pcre-config for libpcre not
found. PCRE is required and available from http://pcre.org/)
下载安装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.启动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
5.安装zlib-1.2.8
cd zlib-1.2.8/
./configure --prefix=/usr/local/zlib
make
sudo make install
6.安装svn
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
make
sudo make install
报错:
configure: error: Subversion requires SQLite
在http://www.sqlite.org官网下载最新版的sqlite-amalgamation.zip,解压缩到subversion-1.8.9目录下新建的sqlite-amalgamation文件夹
unzip sqlite-amalgamation-3080403.zip
7.创建配置库根目录并赋权:
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/
8.配置apache的httpd文件
cp /usr/local/svn/libexec/mod_dav_svn.so /usr/local/apache/modules/
cp /usr/local/svn/libexec/mod_authz_svn.so /usr/local/apache/modules/
vi /usr/local/apache/conf/httpd.conf
a修改User和Group为apache账号启动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-------------权限控制文件
9.创建代码库,并增加svn用户,赋予权限
sudo /usr/local/svn/bin/svnadmin create /usr/svn_root/repository/repo1
sudo /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf
wwl
New password:
Re-type new password:
Adding password for user
wwl
sudo /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf
apache
sudo /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf
test1
sudo /usr/local/apache/bin/htpasswd /usr/svn_root/config/passwd.conf
test2
第一次增加需要加-c参数(创建新的passwd.conf文件)
vi /usr/svn_root/config/authz.conf
[groups]
admin = wwl
CM = apache
test = test1,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的权限继承关系
10.重启apache:
增加repo1代码库里面文件并上传后,重启apache会看到:
sudo ./usr/local/apache/bin/apachectl restart
题外话:
每次输svn、apache命令都要写绝对地址好烦,ln是你的好帮手
sudo ln /usr/local/svn/bin/* /usr/bin
sudo ln /usr/local/apache/bin/* /usr/bin
Ubuntu 源码方式安装Subversion+Apache2,布布扣,bubuko.com