centos下svn与mysql_centos6.5安装SVN实现HTTP访问和MYSQL验证

这个主要参考了这篇博客http://blog..com/denghaibin/1554829,然后把自己走过的一些坑填平,没有什么原创成分。

为了方便,我的SVN,MYSQL,APACHE都是用yum安装的,还要再安装一部分插件。yum -y install mysql mysql-devel mysql-server httpd mod_auth_mysql subversion mod_dav_svn创建SVN目录mkdir -p /svn/创建一个项目名字叫做PHPsvnadmin create /svn/php

修改项目配置文件vim /svn/php/conf/authz

接下来我们给配置文件里添加几个组,分别为admin组,php组,java组,IOS组,Android组 。[groups]

admin = wangxiaolong,songxibo

php = liuwanli,lishuai,yanjiaqi,zhangyou,

android = zhangqi,xuyupeng

ios = hanqi

java = qinjiang

[/]

@admin = rw

[php:/]

@php = rw给项目增加apache的访问权限chown -R apache.apache /svn/chmod 755 /svn/ -R

启动数据库service mysqld start

初始化数据库,顺便设置root密码mysql_secure_installation

敲回车——输入要设置的root密码——再次确认输入root密码——y——y——y——y——结束。[root@svn ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y

... Success!

By default, MySQL comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

[root@svn ~]#接下来我们进入数据库mysql -uroot -p

输入数据库密码进入数据库。

接下来新建一个SVN的数据库create database svn_auth;使用该数据库use svn_auth;创建一个用户表,包含user_name和user_passwd。CREATE TABLE users ( user_name CHAR(30) NOT NULL,user_passwd CHAR(20) NOT NULL,PRIMARY KEY (user_name));

创建账户,此处账户要和/svn/php/conf/auth里的用户保持一致。此处我们只创建两个测试账户即可。insert into svn_auth.users values('wangxiaolong',encrypt('123456'));

insert into svn_auth.users values('lishuai',encrypt('123456'));退出数据库,修改apache配置文件vim /etc/httpd/conf/httpd.conf修改ServerName www.example.com修改为ServerName localhost不该也可以,就是启动apache时候有个提示而已。

然后再最底下加入SVN的配置,(自己用的话,去掉注释,否则会报错)

DAV svn

SVNParentPath /svn/ #项目的父目录

AuthzSVNAccessFile /svn/php/conf/authz #svn访问认证文件

AuthName "JKSLW SUBVERSION" #认证名称

AuthType Basic #基本认证

AuthMYSQLEnable on #开启mysql认证

AuthMYSQLUser root #数据库访问用户名

AuthMySQLPassword 123456 #数据库访问的密码

AuthMYSQLDB svn_auth #存放认证信息的数据库名称

AuthMYSQLUserTable users #存放认证信息的表名称

AuthMYSQLNameField user_name #存放认证用户名的字段名称

AuthMYSQLPasswordField user_passwd #存放认证密码的字段名称

Require valid-user

保存退出后,重启apacheservice httpd restart防火墙放开80端口vim /etc/sysconfig/iptables在22端口通过的行的下面加入-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT重启iptablessservice iptables restart

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值