Linux系统设置frp开机自动启动
之前写过一篇关于搭建frp服务的文章,里面采用的后台启动方式有一个很大的弊端,就是系统重启之后,frp的服务就要手动开启一次才能正常运行,这实在是不能忍的,现在都什么年代了,现在都流行自动化了,所以必须要让frp开机启动。本文只讲ubuntu系统和centos系统,这两个系统使用率较高,windows系统的还没实践过就先不讲。
ubuntu系统下:
第一步:下载安装Ubuntu下常用的进程管理器supervisor:
sudo apt install supervisor -y
第二步:在/etc/supervisor/conf.d下新建一个配置文件frp.conf。输入以下内容。command 是放置frp的位置。
vim /etc/supervisor/conf.d/frp.conf
客户端:
[program:frp]
command = /etc/frp/frpc -c /etc/frp/frpc.ini
autostart = true
服务端:
[program:frp]
command = /etc/frp/frps -c /etc/frp/frps.ini
autostart = true
重启supervisor
sudo systemctl restart supervisor
查看运行状态:
sudo systemctl status supervisor
查看frp服务是否已经启动
ps -ef | grep frp
最后设置supervisor开机启动
sudo systemctl enable supervisor
centos7系统下
例如:frp的文件路径是/etc/frp/下
客户端:
第一步:cp /etc/frp/frpc /usr/local/bin/frpc
第二步:vim /lib/systemd/system/frpc.service
填入一下内容:
[Unit]
Description=frpc service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
ExecStart=/etc/frp/frpc -c /etc/frp/frpc.ini
[Install]
WantedBy=multi-user.target
保存退出
systemctl daemon-reload
systemctl start frpc #启动frpc
systemctl status frpc #查看状态
systemctl enable frpc #设置开机启动
服务端:
第一步:cp /etc/frp/frps /usr/local/bin/frps
第二步:vim /lib/systemd/system/frps.service
填入一下内容:
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
ExecStart=/etc/frp/frps -c / etc/frp/frps.ini
[Install]
WantedBy=multi-user.target
保存退出
systemctl start frps #启动frps
systemctl status frps #查看状态
systemctl enable frps #设置开机启动
版权声明:本博客所有文章除特殊声明外,均采用 CC BY-NC 4.0 许可协议。转载请注明出处 caijinbo的博客!