ubuntu 上安装和配置Apache2+Subversion

目录

一、安装Apache2和SVN

二、Apache2设置

三、subversion配置

四、创建仓库和设置权限

五、仓库备份和恢复


系统环境

Ubuntu Linux (20.04) + apache2 + Subversion(1.13.0)

一、安装Apache2和SVN

通过命令在线安装apache2和subversion

apt-get install apache2 libapache2-mod-svn subversion
二、Apache2设置

1.修改apache默认端口

我这里有冲突,所以将listen修改成8818。我不需要https访问,所有不需要安装和配置SSL相关。

vim /etc/apache2/ports.conf

2.重启apache

systemctl start apache2

3.查看apache2状态并通过网页访问

systemctl status apache2
三、subversion配置

1.验证SVN是否安装成功

svn --version

2.创建svn根目录(版本库主目录)

mkdir -p /data/svn

3.svn与apache整合

修改dav_svn配置

vim /etc/apache2/mods-enabled/dav_svn.conf

<Location /svn> #/svn表示            http://hostname/svn/myproject
        DAV svn
        SVNParentPath /data/svn/
        AuthType Basic
        AuthName "Subversion Repository"
        AuthUserFile /data/svn/passwd
        AuthzSVNAccessFile /data/svn/authz
        Require valid-user
</Location>

验证用户名密码的数据文件 passwd

验证用户的权限配置文件 authz

4.创建密码文件

生成账号(会要求输入2次密码,保存会加密)第一次需要加c,第二次就不要了

htpasswd -c /data/svn/passwd admin

5.创建权限文件

touch /data/svn/authz

可以参考下面的内容

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[/]
admin = rw
!=

这里 [/] 表示根目录,所有仓库。admin = rw 表示admin账号有读写权限

6.启动SVN服务

svnserve -d -r /data/svn

启动SVN服务器,这里说明下:

-d:表示在后台运行

-r:指定服务器的根目录

停止服务器的命令:killall svnserve

7.查看进程

ps -aux | grep svnserve

四、创建仓库和设置权限

1.创建sourcecode仓库

svnadmin create /data/svn/sourcecode

2.修改当前仓库的配置文件

vim  /data/svn/sourcecode/conf/svnserve.conf 

去掉这几段话之前的#

anon-access = none #关闭匿名访问

auth-access = write #验证用户可写

password-db = passwd #指向验证用户名密码的数据文件 passwd

auth-db=authz #指向验证用户的权限配置文件 authz

3.授权仓库目录权限

chmod -R 777 /data/svn/sourcecode

4.网页访问

http://192.168.31.200:8818/svn/sourcecode/

会弹窗验证密码,验证刚刚的admin账号就行了

5.删除仓库

删除现有的仓库

rm -rf /data/svn/sourcecode
五、仓库备份和恢复

1.备份仓库

将现有仓库导出成dump文件

svnadmin dump /data/svn/sourcecode > sourcecode.dump

2.恢复仓库

先创建空白仓库,再将dump文件恢复到仓库上

cd /data/svn/

svnadmin create sourcecode

svnadmin load /data/svn/sourcecode < /data/svndump/sourcecode.dump
相关推荐
zhangphil7 小时前
Windows环境Apache httpd 2.4 web服务器加载PHP8:Hello,world!
php·apache·httpd
邓草2 天前
帝国CMS系统开启https后,无法登陆后台的原因和解决方法
linux·php·apache
卓琢2 天前
(一)Web 网站服务之 Apache
前端·apache
微刻时光2 天前
Linux编译部署PHP环境
linux·开发语言·redis·git·php·apache·composer
卓琢2 天前
Web 网站服务(二):深入探索 Apache 的高级功能
前端·apache
栀栀栀栀栀栀3 天前
Apache POI 2024/10/2
apache
武子康3 天前
大数据-153 Apache Druid 案例 从 Kafka 中加载数据并分析
java·大数据·分布式·flink·kafka·apache
zhangphil4 天前
Windows安装启动apache httpd 2.4 web服务器
apache
武子康4 天前
大数据-154 Apache Druid 架构与原理详解 基础架构、架构演进
java·大数据·clickhouse·hdfs·架构·flink·apache
倩倩_ICE_王王4 天前
Apache安装后无法启动的问题“不能再本地计算机启动apache”
bug·apache