正在努力加载中QAQ
yum -y install subversion
mkdir -p /svn ##创建目录
svnadmin create /svn/php ##创建php版本库
svnadmin create /svn/android ##创建android版本库
创建完后在根目录会生成svn目录,里面会有php和android版本库文件夹;
接着进到php目录里面将conf文件夹移动到svn目录下,然后把android版本库文件夹里面的conf文件夹整个删除
vi passwd
[users]
# harry = harryssecret
# sally = sallyssecret
admin = admin123
admin1 = 123456
admin2 = 123456
admin3 = 123456
参数说明
gg是分组用来处理多账户权限管理
[php:/]表示php的那个svn库
@gg= rw 表示gg分组的所有用户都有读写权限
admin3 = rw 表示admin3 有读写权限
* = 表示 其他所有匿名账户不允许访问
* = r 表示允许匿名账户读
* = rw 表示允许匿名账户读写
vi authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
gg = admin,admin1,admin2
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[php:/]
@gg = rw
admin3 = rw
* =
[android:/]
@gg = rw
* =
主要开启
anon-access = read
auth-access = write
password-db = /svn/conf/passwd
authz-db = /svn/conf/authz
realm = My First /svn
注:记得将左侧空格全部顶格
参数说明
auth-access 是给svn库开启读写
realm svn库的根目录以下 如果不是多个库访问一套配置文件 则默认路径即可不用修改
password-db 是用户名密码文件的路径 因为要多个库访问同一个配置所以这里需要改为文件绝对路径
authz-db 账户权限文件路径
vi svnserve.conf
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = read
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = /svn/conf/passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = /svn/conf/authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
realm = My First /svn
killall svnserve 关闭服务
svnserve -d -r /svn --config-file=/svn/conf/svnserve.conf(多个库访问一个配置文件需要指定配置文件的位置用整个代码启动服务)
ps aux | grep svnserve #查看服务是否启动
netstat -an | grep 3690 查询svn默认端口有没有打开
如果没有打开编辑
vi /etc/sysconfig/iptables
以下是我的配置文件
# Generated by iptables-save v1.4.7 on Tue Jan 15 15:48:51 2019
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3690 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -j ACCEPT
-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -j ACCEPT
-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -j ACCEPT
-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Jan 15 15:48:51 2019
添加对应的端口号确定无误保存退出后
service iptables restart或者/etc/rc.d/init.d/iptables save
最后最最重要的一步
登录到阿里云控制台添加安全组规则端口,最后就可以搞事了~
vi /etc/rc.d/rc.local
添加
svnserve -d -r /svn --config-file=/svn/conf/svnserve.conf
cd到web目录 cd /www/wwwroot/
将php版本库检出 svn co svn://ip:端口/php
cd到版本库目录 cd /www/server/svn/php/hooks
添加post-commit脚本
vi post-commit
由于svn目录越来越大,文件越来越多的时候,svn提交会扫描整个目录会越来越慢
所以做了以下优化,指定修改的文件才更新,具体脚本如下
#!/bin/sh
REPOS="$1"
REV="$2"
export LANG="zh_CN.UTF-8" #防止乱码
SVN_PATH=/usr/bin/svn #svn命令
SVNDATA_PATH=/www/server/svn/php #版本库路径
WEB_PATH=/www/wwwroot/php #网站目录指定到检出的php版本库
LOG_PATH=/var/log/svn_update.log #svn更新日志文件
echo "##########开始提交 " `date "+%Y-%m-%d %H:%M:%S"` '##################' >> $LOG_PATH
for change_dir in `svnlook dirs-changed $SVNDATA_PATH`
do
$SVN_PATH update --username "seven" --password "123456" --no-auth-cache -N $WEB_PATH/$change_dir >> $LOG_PATH
done
echo `whoami`,$REPOS,$REV >> $LOG_PATH
chown -R www:www $WEB_PATH/$change_dir
修改post-commit的可执行权限
chmod 755 post-commit
最后就可以在windows下用TortoiseSVN检出版本库新建文件添加然后提交测试是否跟web目录同步