2019-08-02 22:16:41 +08:00
|
|
|
|
# Pgyvpn 在 Linux 上的安装和使用
|
|
|
|
|
|
|
|
|
|
Pgyvpn 也就是蒲公英,用于组建虚拟局域网,在国内比较稳定。官网提供了 RPM 和 DEB 包,但是不支持这两种包的系统如何安装呢?可以通过解压 RPM 包的方式实现。
|
|
|
|
|
|
|
|
|
|
## 安装
|
|
|
|
|
|
|
|
|
|
rpmextract 可以解压 RPM 包,这个是一个 sh 脚本,使用方式如下:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```bash
|
|
|
|
|
$ rpmextract.sh PgyVPN_CentOS_2.2.0_X86_64.rpm
|
|
|
|
|
$ ls
|
2019-08-02 22:16:41 +08:00
|
|
|
|
usr etc
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
将得到 usr 和 etc 目录,etc 目录下是 init.d 脚本,可以忽略。重点是 usr 目录,将其中的 sbin 和 share 与 /usr/sbin 和 /usr/share 目录合并即可。
|
|
|
|
|
|
|
|
|
|
## 作为服务运行
|
|
|
|
|
|
|
|
|
|
作为服务运行前需要先手动执行一次 pgyvpn,让系统记住蒲公英 ID 号和密码(由蒲公英管理程序分配)。然后创建两个 systemd service,其中 pgymonitor.service 如下:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```ini
|
2019-08-02 22:16:41 +08:00
|
|
|
|
[Unit]
|
|
|
|
|
Description=PgyVPN
|
|
|
|
|
After=syslog.target
|
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
# Modify these two values and uncomment them if you have
|
|
|
|
|
# repos with lots of files and get an HTTP error 500 because
|
|
|
|
|
# of that
|
|
|
|
|
RestartSec=2s
|
|
|
|
|
Type=simple
|
|
|
|
|
User=root
|
|
|
|
|
Group=root
|
|
|
|
|
ExecStart=/usr/share/pgyvpn/script/pgyvpn_monitor >/dev/null 2>&1 &
|
|
|
|
|
Restart=always
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
另一个服务 pgyvpn.service 内容如下:
|
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```ini
|
2019-08-02 22:16:41 +08:00
|
|
|
|
[Unit]
|
|
|
|
|
Description=PgyVPN
|
|
|
|
|
After=syslog.target
|
|
|
|
|
After=network.target
|
|
|
|
|
After=pgymonitor.service
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
# Modify these two values and uncomment them if you have
|
|
|
|
|
# repos with lots of files and get an HTTP error 500 because
|
|
|
|
|
# of that
|
|
|
|
|
RestartSec=2s
|
|
|
|
|
Type=simple
|
|
|
|
|
User=root
|
|
|
|
|
Group=root
|
|
|
|
|
ExecStart=/usr/sbin/pgyvpn -a > /dev/null 2>&1 &
|
|
|
|
|
Restart=always
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
```
|