树莓派搭建轻量级Web服务器[5]

当树莓派重启后,frp服务并不会自动行启动,因而需要设置开机后自动开启frp
ssh连接上树莓派后,新建frp.service

sudo vi /lib/systemd/system/frp.service

写入下列代码

#frp.service
[Unit]
Description=frp
After=network.target
[Service]
User=root
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=“frc绝对路径”/frpc -c “frc绝对路径”/frpc.ini
[Install]
WantedBy=multi-user.target

保存后执行:

sudo systemctl enable frp
sudo systemctl start frp

为了便于远程管理,可在frp客户端中(树莓派)添加ssh端口

sudo vi “frp路径”/frpc.ini

插入ssh部分代码

[ssh]
type = tcp
local_port = 22
remote_port = 自定义remote端口

You may also like

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.