在Ubuntu7.04上实现apache2.2.4+subversion1.4.4+mod_auth_mysql3.0.0+mysql5.0.28
作者:陈绪
来自:linux宝库(
http://www.linuxmine.com)
电邮:linuxmine#gmail.com
时间:2007年7月15日
1 做好准备工作
apt-get install samba
(以便向linux机器上传送相关tgz/bz2文件)
apt-get install mysql-server
apt-get install mysql-client
(apache认证时需要)
apt-get install zlib1g-dev
(编译subversion时需要)
apt-get install libmysqlclient15-dev
(编译mod_auth_mysql时需要)
2 编译安装http 2.2.4
tar xvfj httpd-2.2.4.tar.bz2
cd httpd-2.2.4
./configure --enable-mods-shared='dav rewrite proxy'
make
make install
主要是将dav模块以so方式编译出来,同时也为后文以so方式载入svn的模块做好准备
3 编译安装subversion
tar xvfz subversion-1.4.4.tar.bz2
cd subversion-1.4.4
./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subverion
make
make install
subversion安装到/usr/local/subversion目录中,同时/usr/local/apache2/conf/httpd.conf中多了两行
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
4 编译安装mod_auth_mysql
4.1 访问
http://sourceforge.net/projects/modauthmysql
下载June 22, 2005的3.0.0版本 mod_auth_mysql-3.0.0.tar.gz
# tar xvfz mod_auth_mysql-3.0.0.tar.gz
# cd mod_auth_mysql-3.0.0
4.2 访问
http://cvs.mandriva.com/cgi-bin/ ... l-3.0.0-apr1x.patch
点击3_0_0-7mdv2007_0,最后下载该补丁,文件名为 mod_auth_mysql-3.0.0-apr1x.patch,放到mod_auth_mysql-3.0.0目录中
# patch -p0 mod_auth_mysql.c < mod_auth_mysql-3.0.0-apr1x.patch
4.3 # /usr/local/apache2/bin/apxs -cia -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
安装mod_auth_mysql,同时
/usr/local/apache2/conf/httpd.conf中多了一行
LoadModule mysql_auth_module modules/mod_auth_mysql.so
5 配置数据库
mysql
> CREATE DATABASE web_auth;
> use web_auth;
> CREATE TABLE user_info (user_name CHAR(30) NOT NULL, user_password CHAR(20) NOT NULL, PRIMARY KEY(user_name));
> insert into user_info values('user1', encrypt('user1'));
> insert into user_info values('user2', encrypt('user2'));
> insert into user_info values('user3', encrypt('user3'));
> insert into user_info values('user4', encrypt('user4'));
字段名是mod_auth_mysql默认的,建议不要修改。
6 配置subversion
6.1 建立版本库
mkdir -p /space/svn
cd /space/svn
/usr/local/subversion/bin/svnadmin create project1
/usr/local/subversion/bin/svnadmin create project2
cd ../
chown -R daemon.daemon svn
6.2 建立subversion授权文件
vi /usr/local/subversion/svn_auth.conf
[groups]
group1 = user1,user2
group2 = user3,user4
[project1:/]
test4 = r
@group1 = rw
[project2:/]
@group2 = rw
@group1 = r
这样就设定了2个项目/2个组/4个用户,其中group1中的user1/user2可对project1进行读写操作,并可对project1进行读操作;group2中的user3/user4可对project2进行读写操作,user4可对project1进行读操作。
7 配置apache的配置文件
vi /usr/local/apache2/conf/httpd.conf
<Location /svn>
DAV svn
SVNParentPath /space/svn
AuthType Basic
AuthUserFile /dev/null
AuthBasicAuthoritative off
AuthName "Subversion repository"
AuthMySQLHost localhost
AuthMySQLUser root
AuthMySQLDB web_auth
AuthMySQLUserTable user_info
AuthMySQLEnable On
AuthMYSQLNoPasswd On
AuthMySQLPwEncryption crypt
AuthzSVNAccessFile /usr/local/subversion/svn_auth.conf
Require valid-user
</Location>
注意:
如果没有AuthUserFile /dev/null,apache的error_log中会出现这样的错误:
[error] Internal error: pcfg_openfile() called with NULL filename
[error] [client ip] (9)Bad file descriptor: Could not open password file: (null)
如果没有AuthBasicAuthoritative off,会出现错误:
[error] [client ip] user yourusername not found:
8 重启apache服务,通过web页面进行访问
/usr/local/apache2/bin/apachectl restart
访问http://servername/svn/project1/
使用4个用户中任何1个的用户名和密码即可访问。
【全文结束】