天天看点

使用systemd配置SVN服务器自动启动

使用systemd配置SVN服务器开机自动启动步骤比较简单。步骤如下:

1) 在/etc/systemd/system/目录创建单元文件,并且保证只能被root用户编辑:

touch /etc/systemd/system/svn.service

chmod 664 /etc/systemd/system/svn.service

其中,“svn.service”是我们自定义的服务单元文件名称,可以根据情况修改,下同。

2)打开svn.service文件,添加服务配置:

[Unit]

Description=Subversion Server

[Service]

Type=forking

ExecStart=/usr/bin/svnserve -d -r /opt/svndata

ExecStop=/usr/bin/killall svnserve

Restart=always

[Install]

WantedBy=default.target

其中,“/opt/svndata”是SVN仓库的根路径,请根据情况修改。

3)通知systemd有个新服务添加:

systemctl daemon-reload

4)启动和停止SVN服务

systemctl start svn.service

systemctl stop svn.service

用于测试刚才创建的服务单元是否工作正常。

5)配置开机自动启动

systemctl enable svn.service

其他有用的命令

1)列出systemd管理的所有服务状态

systemctl list-units --type service --all

2)检查SVN服务运作状态

systemctl status svn.service

继续阅读