晨风

-------------------- 业精于勤,荒于嬉;行成于思,毁于随

导航

Frp后台自动启动的几个方法

Posted on 2025-03-05 14:51  shenyixin  阅读(485)  评论(0)    收藏  举报

1使用nohup来启动

这是frps的后台启动,如果要查看日志的话,就直接使用tail -f nohup.out,就可以查看了。

nohup /usr/local/frp_0.32/fprs -c /usr/local/frp_0.32/frps.ini

这是frpc的后台启动

nohup /usr/local/frp_0.32/fprc -c /usr/local/frp_0.32/frpc.ini

2使用systemctl来控制启动(推荐使用)

sudo vim /lib/systemd/system/frps.service

在frps.service里写入以下内容

[Unit]
Description=fraps service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
#启动服务的命令
ExecStart=/usr/local/frp_0.32/frps -c /usr/local/frp_0.32/frps.ini

[Install]
WantedBy=multi-user.target

然后就启动frps

sudo systemctl start frps

再打开自启动

sudo systemctl enable frps

重启:sudo systemctl restart frps

停止:sudo systemctl stop frps

状态:sudo systemctl status frps

3使用supervisor来控制

ubuntu为例,先安装supervisor

sudo apt install supervisor

创建 supervisor frps 配置文件,在 /etc/supervisor/conf.d 创建 frp.conf

[program:frp]
command = /usr/local/frp_0.32/frps -c /usr/local/frp_0.32/frps.ini
autostart = true

保存后,要重新加载一下supervisor

# 重启supervisor
sudo systemctl restart supervisor
# 查看supervisor运行状态
sudo supervisorctl status