方式一:centos 7 設置svn開機自啟動 使用新的systemctl 服務命令 (筆者成功驗證過,該方式可行)
- [root@iZjvr37lpviqbkZ init.d]# vi /lib/systemd/system/svnserve.service
- [root@iZjvr37lpviqbkZ init.d]# vi /etc/sysconfig/svnserve
- [root@iZjvr37lpviqbkZ init.d]# systemctl enable svnserve.service
- Created symlink from /etc/systemd/system/multi-user.target.wants/svnserve.service to /usr/lib/systemd/system/svnserve.service.
安裝好 svn 服務后,默認是沒有隨系統啟動自動啟動的, CentOS 7 的 /etc/rc.d/rc.local 是沒有執行權限的, 系統建議創建 systemd service 啟動服務
於是查看 systemd 里 svn 的配置文件 /lib/systemd/system/svnserve.service
- [Unit]
- Description=Subversion protocol daemon
- After=syslog.target network.target
- [Service]
- Type=forking
- EnvironmentFile=/etc/sysconfig/svnserve
- ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS
- [Install]
- WantedBy=multi-user.target
找到 svn 的 service 配置文件 /etc/sysconfig/svnserve 編輯配置文件
- vi /etc/sysconfig/svnserve
將 OPTIONS="-r /var/svn" 改為 svn 版本庫存放的目錄,:wq 保存退出
在提示符下輸入
- systemctl enable svnserve.service
- systemctl start svnserve.service
查看服務列表狀態
- systemctl list-units --type=service
systemctl list-unit-files
重啟服務器,輸入
- ps -aux | grep 'svn'
看 svn 服務啟動了沒有
