Centos7

下载frp:https://github.com/fatedier/frp/releases 我下载的是: frp_0.29.1_linux_amd64.tar.gz 在root用户下,根据下面步骤进行配置安装

1、服务端安装:

  1. wget https://github.com/fatedier/frp/releases/download/v0.29.1/frp_0.29.1_linux_amd64.tar.gz
  2. tar -vxzf frp_0.29.1_linux_amd64.tar.gz
  3. cd frp_0.29.1_linux_amd64
  4. c frps /usr/bin/
  5. mkdir -p /etc/frp
  6. cp frps.ini frps_full.ini /etc/frp/
  7. cp systemd/frps.service /usr/lib/systemd/system/
  8. cd /usr/lib/systemd/system/
  9. systemctl enable frps

    2、编辑服务文件:vim /usr/lib/systemd/system/frps.service

  10. [Unit]

  11. Description=Frp Server Service
  12. After=network.target
  13. [Service]

  14. Type=simple
  15. User=root
  16. Restart=on-failure
  17. RestartSec=5s
  18. ExecStart=/usr/bin/frps -c /etc/frp/frps.ini
  19. ExecStop=/bin/kill $MAINPID
  20. [Install]

  21. WantedBy=multi-user.target

    3、编辑配置文件:vim /etc/frp/frps.ini

  22. [common]

  23. bind_port = 7000
  24. subdomain_host = dev.gzcyou.com
  25. vhost_http_port = 80
  26. log_file = /var/log/frps.log

    4、启动frp服务端:

  27. systemctl start frps

    5、客户端安装:

  28. wget https://github.com/fatedier/frp/releases/download/v0.29.1/frp_0.29.1_linux_amd64.tar.gz

  29. tar -vxzf frp_0.29.1_linux_amd64.tar.gz
  30. cd frp_0.29.1_linux_amd64
  31. cp frpc /usr/bin/
  32. mkdir -p /etc/frp
  33. cp frpc.ini frpc_full.ini /etc/frp/
  34. cp systemd/frpc.service /usr/lib/systemd/system/
  35. cd /usr/lib/systemd/system/
  36. systemctl enable frpc

    6、编辑服务文件:vim /usr/lib/systemd/system/frpc.service

  37. [Unit]

  38. Description=Frp Client Service
  39. After=network.target
  40. [Service]

  41. Type=simple
  42. User=root
  43. Restart=on-failure
  44. RestartSec=5s
  45. ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini
  46. ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini
  47. ExecStop=/bin/kill $MAINPID
  48. [Install]

  49. WantedBy=multi-user.target

    7、编辑配置文件:vim /etc/frp/frpc.ini

  50. [common]

  51. server_addr = 121.42.26.59
  52. server_port = 7000
  53. log_file = /var/lib/frpc.log
  54. [ssh]

  55. type = tcp
  56. local_ip = 127.0.0.1
  57. local_port = 22
  58. remote_port = 6000
  59. [web_jenkins]

  60. type = http
  61. local_port = 8080
  62. subdomain = jenkins

    9、启动frp客户端:

  63. systemctl start frpc

    10、其他命令:

  64. systemctl status frpc

  65. systemctl daemon-reload
  66. systemctl list-units —type=service —all
  67. systemctl #列出所有的系统服务
  68. systemctl list-units #列出所有启动unit
  69. systemctl list-unit-files #列出所有启动文件
  70. systemctl list-units –type=service –all #列出所有service类型的unit
  71. systemctl list-units –type=service –all grep cpu #列出 cpu电源管理机制的服务
  72. systemctl list-units –type=target –all #列出所有target
  73. 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