vim /usr/lib/systemd/system/frps.service
#服务内容为
[Unit]
Description=frps
After=network.target
 
[Service]
TimeoutStartSec=30
ExecStart=/usr/local/bin/frps -c /etc/frp/frps.ini  
#这里是执行文件的路径和配置文件的路径
ExecStop=/bin/kill $MAINPID
 
[Install]
WantedBy=multi-user.target

解析一下:

[Unit]

Description=Frp Server Service # 服务描述

After=network.target # frps 将会在 network.service 启动完毕之后再启动

[Service]

Type=simple # 不论进程是否启动成功,systemctl start 都执行成功

User=nobody # 设置进程在执行时使用的用户 为了不报错 最好直接用 root

Restart=on-failure # on-failure 表示仅在服务进程异常退出时重启

RestartSec=5s # 设置在重启服务前暂停多长时间

ExecStart=/usr/bin/frps -c /etc/frp/frps.ini # 在启动该服务时需要执行的命令行

[Install]

WantedBy=multi-user.target # 用于 systemctl enable 时创建软连接

————————————————

==============================================================

第一、启动、终止、重启

#systemctl start frpc.service #启动

#systemctl stop frpc.service #停止

#systemctl restart frpc.service #重启

第二、设置开机启动/关闭

#systemctl enable frpc.service #开机启动

#systemctl disable frpc.service #开机不启动

第三、检查frpc状态

#systemctl status frpc.service

第四、查看所有已启动的服务

#systemctl list-units --type=service

FRP下载地址:

https://github.com/fatedier/frp/rele

最后修改:2023 年 02 月 19 日
如果觉得我的文章对你有用,请随意赞赏