原材料准备(在服务端和客户端均执行一次)
- 下载压缩包
wget https://github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_linux_amd64.tar.gz
- 执行以下命令,解压frp工具包。
tar -xvf frp_0.38.0_linux_amd64.tar.gz
- 执行以下命令,移动至/usr/local
mkdir /usr/local/frp
mv frp_0.38.0_linux_amd64/* /usr/local/frp/
服务端操作
- 服务端修改配置
cd /usr/local/frp
vi frps.ini
填入以下配置[common] bind_addr = 0.0.0.0 bind_port = 7000 token = yuxlfrp vhost_http_port = 80 vhost_https_port = 443 #subdomain_host = yu-xl.com dashboard_port = 7500 dashboard_user = admin dashboard_pwd = admin # frp日志配置 log_file = /var/log/frps.log log_level = info log_max_days = 3
- 启动
./frps -c ./frps.ini
客户端端操作
- 客户端修改配置
cd /usr/local/frp
vi frpc.ini
填入以下配置[common] server_addr = 111.67.195.112 server_port = 7000 token = yuxlfrp user = test1 #[webhttp] #type = http #local_port = 8080 #custom_domains = dream.yu-xl.com [webhttps] type = https local_port = 8443 custom_domains = dream.yu-xl.com
- 启动
./frpc -c ./frpc.ini
服务化
服务端服务化
- 创建配置文件
vim /lib/systemd/system/frps.service
- 写入配置
[Unit] Description=fraps service After=network.target syslog.target Wants=network.target [Service] Type=simple #启动服务的命令(此处写你的frps的实际安装目录) ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.ini [Install] WantedBy=multi-user.target
- 命令集合
systemctl start frps #启动 systemctl enable frps #开启自启 systemctl restart frps #重新启动 systemctl stop frps #停止 systemctl status frps #查看状态
客户端端服务化
- 创建配置文件
vim /lib/systemd/system/frpc.service
- 写入配置
[Unit] Description=fraps service After=network.target syslog.target Wants=network.target [Service] Type=simple #启动服务的命令(此处写你的frpc的实际安装目录) ExecStart=/usr/local/frp/frpc -c /usr/local/frp/frpc.ini [Install] WantedBy=multi-user.target
- 命令集合
systemctl start frpc #启动 systemctl enable frpc #开启自启 systemctl restart frpc #重新启动 systemctl stop frpc #停止 systemctl status frpc #查看状态