要使用 systemd 来控制 frps,需要先安装 systemd,然后在 /etc/systemd/system 目录下创建一个 frps.service 文件
- 安装systemd
# yum
yum install systemd
# apt
apt install systemd
- 创建并编辑 frps.service 文件
[Unit]
Description=Frp Server Service #服务的描述信息
After=network.target #其中network.target代表有网路,network-online.target代表一个连通着的网络。
[Service]
Type=simple
User=nobody
Restart=1 # 如果这个服务停止了,那么就重启
RestartSec=5s
ExecStart=/usr/bin/frps -c /etc/frp/frps.ini #服务的启动命令
[Install]
WantedBy=multi-user.target
$ vim /etc/systemd/system/frps.service
写入内容
[Unit]
服务名称,可自定义
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
启动frps的命令,需修改为您的frps的安装路径
ExecStart = /path/to/frps -c /path/to/frps.ini
[Install]
WantedBy = multi-user.target
-
使用 systemd 命令,管理 frps
systemctl start frps
systemctl stop frps
systemctl restart frps
systemctl status frps -
配置 frps 开机自启
systemctl enable frps