首先根据上面的官网安装srs,我用的是源码编译也挺方便的。
# 编辑配置文件
vim /usr/lib/systemd/system/srs.service
内容(srs的安装目录需要改成自己的)
[Unit]
Description=The SRS Media Stream Cluster
After=network.target
[Service]
Type=forking
WorkingDirectory=/myproject/srs/trunk/
ExecStart=/myproject/srs/trunk/etc/init.d/srs start
ExecRelpad=/myproject/srs/trunk/etc/init.d/srs reload
ExecStop=/myproject/srs/trunk/etc/init.d/srs stop
Restart=on-abnormal
RestartSec=5s
KillMode=mixed
[Install]
WantedBy=multi-user.target
保存配置文件
# 更新配置
systemctl daemon-reload# 启动服务
systemctl start srs# 查看srs服务状态
systemctl status srs# 设置开机启动
systemctl enable srs
之后可以通过重启虚拟机,使用systemctl status srs 验证是否开机启动。