启动Frps
使用systemctl来控制frps的启动
参考教程:[systemctl教程](https://www.cnblogs.com/chenshy/p/13514248.html)
---
# 服务端配置
配置文件的目录,位于`/usr/lib/systemd/system`
```js
sudo vi /lib/systemd/system/frps.service
```
粘贴以下内容,注意修改文件的路径
```js
[Unit]
Description=fraps service
After=network.target network-online.target syslog.target
Wants=network.target network-online.target
[Service]
Type=simple
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/root/frp/frp_0.51.3_linux_amd64/frps -c /root/frp/frp_0.51.3_linux_amd64/frps.ini
[Install]
WantedBy=multi-user.target
```
按`ESC`退出编辑模式,输入`:wq`退出编辑并保存。
>d 注意输入的完整性。
如果输入不完整,可以手动进入`/usr/lib/systemd/system`目录,编辑`frps.service`文件。
# 重载配置文件
```
sudo systemctl daemon-reload
```
# 启动frps
```
sudo systemctl start frps
```
# 打开自启动
```
sudo systemctl enable frps
```
# 重启应用
```
sudo systemctl restart frps
```
# 停止应用
```
sudo systemctl stop frps
```
# 查看应用的日志
```
sudo systemctl status frps
```
# 停止开机自启动
```
systemctl disable frps
```
# 查看frp线程
```
ps -aux | grep frp
```
相关的运行日志:
```cmd
Last login: Thu Nov 23 16:04:48 2023 from 127.0.0.1
[root@VM-0-4-centos ~]# sudo systemctl daemon-reload
[root@VM-0-4-centos ~]# sudo systemctl start frps
[root@VM-0-4-centos ~]# sudo systemctl enable frps
Created symlink from /etc/systemd/system/multi-user.target.wants/frps.service to /usr/lib/systemd/system/frps.service.
[root@VM-0-4-centos ~]# ps -aux | grep frp
root 3280 0.7 0.2 728964 17240 ? Ssl 16:06 0:00 /root/frp/frp_0.51.3_linux_amd64/frps -c /root/frp/frp_0.51.3_linux_amd64/frps.ini
root 3446 0.0 0.0 112812 980 pts/0 S+ 16:07 0:00 grep --color=auto frp
[root@VM-0-4-centos ~]#
```