Frp后台自动启动的几个方法
1.使用nohup
这是frps的后台启动(路径写你服务器上的绝对路径),如果要查看日志的话,就直接使用cat nohup.out,就可以查看了。
nohup /path/to/your/fprs -c-c /path/to/your/frps.ini
这是frpc的后台启动
nohup /path/to/your/fprc -c-c /path/to/your/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
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/your/path/frps -c /your/path/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
首先先安装supervisor,我用的ubuntu
sudo apt install supervisor
创建 supervisor frps 配置文件,在 /etc/supervisor/conf.d 创建 frp.conf
[program:frp]
command = /your/path/frps -c /your/path/frps.ini
autostart = true
同样是你的绝对路径。
写完以后,要重新加载一下supervisor
# 重启supervisor
sudo systemctl restart supervisor
# 查看supervisor运行状态
sudo supervisorctl status
多说一句,这是写的frps的后台启动,frpc的话,类比一下就可以了。