Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save crosstyan/d24035051d0b13113ec99be0dcdccb68 to your computer and use it in GitHub Desktop.
Save crosstyan/d24035051d0b13113ec99be0dcdccb68 to your computer and use it in GitHub Desktop.
Install frp as systemd service
# Update in 2023/06/19
# 1. frp no longer provide systemctl service file. This script creates frpc/fprs systemctl service file by itself
# 2. Update frp from 0.33.0 to 0.49.0
# 3. User=nobody is no longer suggested, use DynamicUser=yes instead
wget https://github.com/fatedier/frp/releases/download/v0.49.0/frp_0.49.0_linux_amd64.tar.gz --directory-prefix=/tmp
DIR=frp_0.49.0_linux_amd64
tar -zxvf /tmp/$DIR.tar.gz -C /tmp
mkdir -p /etc/frp
cp /tmp/$DIR/frpc.ini /etc/frp/frpc.ini
cp /tmp/$DIR/frps.ini /etc/frp/frps.ini
cp /tmp/$DIR/frpc /usr/bin/
cp /tmp/$DIR/frps /usr/bin/
echo '[Unit]
Description=Frp Client Service
After=network.target
[Service]
Type=simple
DynamicUser=yes
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini
ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/frpc.service
echo '[Unit]
Description=Frp Server Service
After=network.target
[Service]
Type=simple
DynamicUser=yes
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/frps -c /etc/frp/frps.ini
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/frps.service
systemctl daemon-reload
systemctl status frpc
systemctl status frps
echo "Modify /etc/frp/frpc.ini or /etc/frp/frps.ini"
echo "And then run"
echo " systemctl enable frps"
echo " systemctl start frps"
echo "or"
echo " systemctl enable frpc"
echo " systemctl start frpc"
echo "to launch the services"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment