在 Linux 系统下,使用systemd 可以方便地控制 frp 服务端 frps 的启动和停止、配置后台运行和开启自启。
要使用 systemd 来控制 frps,需要先安装 systemd,然后在 /etc/systemd/system 目录下创建一个 frps.service 文件。
- 如Linux服务端上没有安装
systemd,可以使用yum或apt等命令安装systemd。# yum yum install systemd # apt apt install systemd - 使用文本编辑器,如
vim创建并编辑frps.service文件。$ 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。# 启动frp systemctl start frps # 停止frp systemctl stop frps # 重启frp systemctl restart frps # 查看frp状态 systemctl status frps - 配置 frps 开机自启。
systemctl enable frps