作者:股民连长 | 来源:互联网 | 2023-08-13 17:14
svn服务器有两种运行方式,一种是基于Apache Http Server,第二种是Subversion Standalone Server
下面用的第二种:
1.安装SVN
快速安装: yum install subversion
2.安装成功后建仓库
创建仓库存放目录
mkdir -p /opt/svn/
创建SVN仓库repos,
mkdir -p /opt/svn/repos
svnadmin create /opt/svn/repos
3.修改配置: (此处要注意: 不能在配置文件中留有空格,可以换行。不然会出现 Authentication failed 错误)
cd /opt/svn/repos/conf vi svnserve.conf
把相应参数修改成下面的
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /opt/svn/repos
说明:
anon-access = none #不允许匿名用户访问
auth-access = write #通过验证的用户可以读和写
password-db = passwd #用户保存文件
authz-db = authz #权限管理文件
realm = /opt/svn/repos #仓库名称
4.设置用户密码:
假设你设置此库的SVN用户名为youname
vi passwd
在最后加入用户名与密码:
youname = 123456
5.设置用户权限:
vi authz
在[/]最后加入: youname =rw
6.添加svn用户启动svn服务
useradd svn passwd svn
根据提示为用户svn设置密码
允许用户svn访问版本库:
chown -R svn:svn /opt/svn
(这里一直出错,后来直接把文件的权限改了 chomd -R 755 /opt/svn/repos)
启动svn
svnserve -d -r /opt/svn/repos --listen-port 3690
3690是svn默认端口,当然你也可更改为其它的但同时要修改防火墙配置
另外的测试方法:
telnet {your-server-ip} 3690
检查端口是不是通的 如果 上面检查不通,有可能是iptables中没有打开,设置iptables就可以:
vi /etc/sysconfig/iptables
添加:
-A OUTPUT -p tcp -m tcp --dport 3690 -j ACCEPT
重启iptables
service iptables restart
7,修改hooks实现同步发布 (一般不用)
假如您要发布的目录是/usr/share/nginx/test 进行你刚才建的库/opt/svn/repos
cd /opt/svn/repos/ cd hooks
cp post-commit.tmpl post-commit
vi post-commit
在post-commit里修改下面代码,没有的请添加
REPOS="$1" REV="$2"
\#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf export LANG=zh_CN.UTF-8
svn export --username youname --password 123456 svn://your.ip/repos /usr/share/nginx/test --force
然后再修改权限
chmod a+x post-commit
好了现在你就可以使用更新即同步发布,如果你要有条件发布的话请修改post-commit里添加个条件判断
svn
查看svn进程 ps aux|grep svnserve
杀死进程 kill -9 进程号
重启SVN svnserve -d -r /opt/svn/repos/
文章通过网络整理
svn
查看svn进程 ps aux|grep svnserve
杀死进程 kill -9 进程号
重启SVN svnserve -d -r /opt/svn/repos/
配置好SVN之后就是将本地的代码提交到服务器上,可以在WEB目录下显示
这里需要在wen目录下检出
svn co svn://你的ip地址/你要检出的项目
文章通过网络整理