Centos7
下载frp:https://github.com/fatedier/frp/releases 我下载的是: frp_0.29.1_linux_amd64.tar.gz 在root用户下,根据下面步骤进行配置安装
1、服务端安装:
- wget https://github.com/fatedier/frp/releases/download/v0.29.1/frp_0.29.1_linux_amd64.tar.gz
- tar -vxzf frp_0.29.1_linux_amd64.tar.gz
- cd frp_0.29.1_linux_amd64
- c frps /usr/bin/
- mkdir -p /etc/frp
- cp frps.ini frps_full.ini /etc/frp/
- cp systemd/frps.service /usr/lib/systemd/system/
- cd /usr/lib/systemd/system/
-
2、编辑服务文件:vim /usr/lib/systemd/system/frps.service
[Unit]
- Description=Frp Server Service
- After=network.target
[Service]
- Type=simple
- User=root
- Restart=on-failure
- RestartSec=5s
- ExecStart=/usr/bin/frps -c /etc/frp/frps.ini
- ExecStop=/bin/kill $MAINPID
[Install]
-
3、编辑配置文件:vim /etc/frp/frps.ini
[common]
- bind_port = 7000
- subdomain_host = dev.gzcyou.com
- vhost_http_port = 80
-
4、启动frp服务端:
-
5、客户端安装:
wget https://github.com/fatedier/frp/releases/download/v0.29.1/frp_0.29.1_linux_amd64.tar.gz
- tar -vxzf frp_0.29.1_linux_amd64.tar.gz
- cd frp_0.29.1_linux_amd64
- cp frpc /usr/bin/
- mkdir -p /etc/frp
- cp frpc.ini frpc_full.ini /etc/frp/
- cp systemd/frpc.service /usr/lib/systemd/system/
- cd /usr/lib/systemd/system/
-
6、编辑服务文件:vim /usr/lib/systemd/system/frpc.service
[Unit]
- Description=Frp Client Service
- After=network.target
[Service]
- Type=simple
- User=root
- Restart=on-failure
- RestartSec=5s
- ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini
- ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini
- ExecStop=/bin/kill $MAINPID
[Install]
-
7、编辑配置文件:vim /etc/frp/frpc.ini
[common]
- server_addr = 121.42.26.59
- server_port = 7000
- log_file = /var/lib/frpc.log
[ssh]
- type = tcp
- local_ip = 127.0.0.1
- local_port = 22
- remote_port = 6000
[web_jenkins]
- type = http
- local_port = 8080
-
9、启动frp客户端:
-
10、其他命令:
systemctl status frpc
- systemctl daemon-reload
- systemctl list-units —type=service —all
- systemctl #列出所有的系统服务
- systemctl list-units #列出所有启动unit
- systemctl list-unit-files #列出所有启动文件
- systemctl list-units –type=service –all #列出所有service类型的unit
- systemctl list-units –type=service –all grep cpu #列出 cpu电源管理机制的服务
- systemctl list-units –type=target –all #列出所有target
- systemctl list-dependencies #查看当前运行级别target(mult-user)启动了哪些服务
⚠️注意:如果服务端是阿里云服务器需要开放端:80,6000,7000
官方文档:https://github.com/fatedier/frp/blob/master/README_zh.md 参考资料:https://www.jianshu.com/p/617972428455
