总结
豆包 AI 助手文章总结
首页 > 运维 > CentOS > 正文

centos上搭建SVN并将项目同步到PHP项目的系统根目录的方法详解

藏色散人
发布: 2020-04-29 12:05:52
转载
1972人浏览过

下面由centos入门教程栏目给大家介绍centos上搭建svn并将项目同步到php项目的系统根目录的方法,希望对需要的朋友有所帮助!

centos上搭建SVN并将项目同步到PHP项目的系统根目录的方法详解

一、SVN安装

这里采用yum安装方式:

1、rpm -qa subversion             //检查是否安装了低版本的SVN

2、yum remove subversion           //如果存储旧版本,卸载旧版本SVN

立即学习PHP免费学习笔记(深入)”;

3、开始安装yum -y install subversion    

安装好后查看版本svnserve --version 

4、创建版本仓库:

mkdir -p /data/svn/project                                
svnadmin create /data/svn/project/
登录后复制

查看/data/svn/project 文件夹可以发现有conf, db,format,hooks, locks, README.txt等文件,说明一个SVN库已经建立。

5、配置权限

   cd /data/svn/project/conf/            //进入配置目录
     vim svnserve.conf                    //编辑配置文件,加入下面五行内容
```
[general]
### The anon-access and auth-access options control access to the``
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete 
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access = read
# auth-access = write
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /data/svn/project
```
登录后复制

6、编辑密码文件,添加用户test 密码123456:

vim passwd  
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
test = 123456
登录后复制

7、编辑权限文件,添加用户test权限

vim authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
[/]
test = rw
登录后复制

8、配置防火墙

vi /etc/sysconfig/iptables
登录后复制

加入:

```
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 3690 -j ACCEPT
```
登录后复制

重启防火墙:service iptables restart                

9、启动SVN:svnserve -d -r /data/svn/              

查看端口状态:netstat -ln | grep 3690  

      

二、给svn添加钩子同步文件到PHP测试环境 (这里PHP项目目录为/var/www/html/project/)

 1、进入版本库下的hooks目录

cd /data/svn/project/hooks/
登录后复制

2、将post-commit.tmpl 复制为 post-commit

cp post-commit.tmpl post-commit
登录后复制

3、给post-commit可执行权限

chmod 0777 post-commit
登录后复制

4、编辑post-commit,注释掉#mailer.py......这一行,添加下面四行,编码问题,如果错误的话可能导致无法同步    成功,可选的有en_US.UTF-8、zh_CN.UTF-8、zh_CN.GB2312,可以一个个试。

vi post-commit
#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf
export.GB2312
SVN=/usr/bin/svn
STATIC_DIR=/var/www/html/project/
${SVN} update  ${STATIC_DIR} --username "test" --password "123456"
登录后复制

5、在提交之前,进行一次checkout代码到指定目录

svn checkout svn://localhost/project /var/www/html/project/
登录后复制

注:如果一直出错:“由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败”;可能是网络端口开放设置问题,因为端口问题导致无法成功checkout项目,可以进入阿里云看看看看有没有允许3690的端口,如果没有3690的端口就添加一条安全组规则。

更多centos技术文章,请当centos教程栏目!

以上就是centos上搭建SVN并将项目同步到PHP项目的系统根目录的方法详解的详细内容,更多请关注php中文网其它相关文章!

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
相关标签:
来源:lmlyz网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
豆包 AI 助手文章总结
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号