创建文件,并输入如下内容:
vi /usr/frp/start_frp
nohup /usr/frp/frps -c /usr/frp/frps.ini >/root/frp_log 2>&1 &
授权:
chmod +x /usr/frp/start_frp
建立自启动脚本:
vi /etc/init.d/frp
输入如下内容:
#!/bin/bash
#
# frp startup script for the server
#
# chkconfig: 2345 90 10
# description: start the frp
#
# Source function library
. /etc/rc.d/init.d/functions
#脚本名称
prog=frp
#frp安装目录
FRP_HOME=/usr/frp
export FRP_HOME
#frp运行命令
FRP_RUN_SERVICE=/usr/frp/start_frp
case "$1" in
start)
echo "Starting frp..."
$FRP_RUN_SERVICE
;;
*)
echo "Usage: $prog {start}"
;;
esac
exit 0
修改文件为可运行文件:
chmod a+x frp
查看frp开机启动情况:
chkconfig --list
如没有,则添加到系统启动队列中:
chkconfig --add frp
重新检查frp开机启动情况,若成功,则应显示如下内容:
frp 0:off 1:off 2:on 3:on 4:on 5:on 6:off
使用下列命令对frp进行重启、停止、启动:
service frp start