Linux frpc system service

This article will not go into details about what frpc is. This article configures frpc as a Linux system service, which can be started by using the systemctl start|stop|restart frpc command.

Proceed as follows:

1. Download client files

Download the required version of the frpc client file from the official website . This article takes as an example.frp_0.49.0_linux_amd64.tar.gz

After downloading, unzip it to the directory you need to place on the Linux server. This article uses the directory as /usr/local/frp/clientan example . After decompression, it looks as follows:

[root@test client]# tree
.
├── frpc
├── frpc_full.ini
├── frpc.ini
├── frps
├── frps_full.ini
├── frps.ini
└── LICENSE

2. Edit the configuration file

Modify frpc.inithe configuration file. This refers to the official website configuration. Because there are various ways to use it, the specific usage is subject to the official website.

Here is a very simple example:

[root@test client]# cat frpc.ini 
[common]
server_addr = frp.test.com
server_port = 7000
token = yourtoken
log_file = ./frpc.log

[testssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 10022

3. Configure as system service

Create /etc/systemd/system/frpc.servicea system service file with the following content:

[Unit]
Deion=Frp Client
After=network.target
Wants=network.target

[Service]
Restart=on-failure
RestartSec= 5
# 这里是最重要的,路径请使用绝对路径
ExecStart=/usr/local/frp/client/frpc -c /usr/local/frp/client/frpc.ini

[Install]
WantedBy=multi-user.target

Finally, follow the following commands to configure the service and start the service

# 刷新服务
systemctl daemon-reload

# 设置开机自启
systemctl enable frpc

# 关闭开机自启
systemctl disable frpc

# 启动服务
systemctl start frpc

# 停止服务
systemctl stop frpc

# 重启服务
systemctl restart frpc

(END)

Guess you like

Origin blog.csdn.net/catoop/article/details/131244857