4

电脑技术:在CentOS上将frp内网穿透服务注册为服务并开启自启动且失效自启动

 2 years ago
source link: https://www.taholab.com/25200
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
TAHOLAB
Primary Navigation Menu

Menu

电脑技术:在CentOS上将frp内网穿透服务注册为服务并开启自启动且失效自启动

By: taho
On: 2022年5月24日
Tagged: 电脑技术
With: 0 Comments

虽然可以通过frp自带的服务文件来做,但事实发现其实不如手动配置来的靠谱,因为还需要做一些修改,所以不如直接手动添加服务。

首先做好frp服务配置,服务端和客户端案例分别如下:


服务端配置和自动设置

创建服务脚本并编辑

vi /etc/systemd/system/frps.service

内容如下:(注意,代码中的frps.ini是服务端配置文件,请依据自己的实际情况做相应修改)

[Unit]
Dcription=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
User=root
Restart=on-failure
ExecStart=/root/frp/frps -c /root/frp/frps.ini
ExecReload=/root/frp/frps -c /root/frp/frps.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
[Install]
WantedBy=multi-user.target

加入服务列表并设置自启动

#重新加载服务列表
systemctl daemon-reload
#将frps加入开机自启动
systemctl enable frps.service
#启动服务
systemctl start frps.service
#以下是其他常用命令
#关闭服务
systemctl stop frps.service
#重启服务
systemctl restart frps.service
#显示服务的状态
systemctl status frps.service
#禁用服务开机启动
systemctl disable frps.service
#查看服务是否开机启动
systemctl is-enabled frps.service
#查看已经启动的服务列表
systemctl list-unit-files|grep enable
#查看启动失败的服务列表
systemctl --failed配置和自启动设置

客户端配置和自动设置

客户端与服务端配置方法完全一致,代码如下:

创建服务脚本并编辑

vi /etc/systemd/system/frpc.service

内容如下:(注意,代码中的frpc.ini是服务端配置文件,请依据自己的实际情况做相应修改)

[Unit]
Dcription=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
User=root
Restart=on-failure
ExecStart=/root/frp/frpc -c /root/frp/frpc.ini
ExecReload=/root/frp/frpc -c /root/frp/frpc.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
[Install]
WantedBy=multi-user.target

加入服务列表并设置自启动

#重新加载服务列表
systemctl daemon-reload
#将frpc加入开机自启动
systemctl enable frpc.service
#启动服务
systemctl start frpc.service
#以下是其他常用命令
#关闭服务
systemctl stop frpc.service
#重启服务
systemctl restart frpc.service
#显示服务的状态
systemctl status frpc.service
#禁用服务开机启动
systemctl disable frpc.service
#查看服务是否开机启动
systemctl is-enabled frpc.service
#查看已经启动的服务列表
systemctl list-unit-files|grep enable
#查看启动失败的服务列表
systemctl --failed

2022-05-24

发表评论 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

评论 *

显示名称 *

电子邮箱地址 *

网站地址

在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK