To manage FRP services using systemd, you need to create systemd service files. This is a more robust way of managing your services and comes with benefits like auto-restarting on crash and easy log management.
-
Create a systemd service file for frps (FRP server)
sudo nano /etc/systemd/system/frps.service
Then paste the following into the file:
[Unit] Description=FRP Server Service After=network.target [Service] ExecStart=/path/to/your/frp/frps -c /path/to/your/frp/frps.ini Restart=on-failure User=nobody Group=nobody [Install] WantedBy=multi-user.target
Replace
/path/to/your/frp/
with the actual path to your FRP binaries. Save and close the file when you’re done. -
Create a systemd service file for frpc (FRP client)
sudo nano /etc/systemd/system/frpc.service
Then paste the following into the file:
[Unit] Description=FRP Client Service After=network.target [Service] ExecStart=/path/to/your/frp/frpc -c /path/to/your/frp/frpc.ini Restart=on-failure User=nobody Group=nobody [Install] WantedBy=multi-user.target
Replace
/path/to/your/frp/
with the actual path to your FRP binaries. Save and close the file when you’re done. -
Reload the systemd manager configuration
This will make systemd recognize your new services:
sudo systemctl daemon-reload
-
Start the services
sudo systemctl start frps sudo systemctl start frpc
-
Enable the services to start at boot
sudo systemctl enable frps sudo systemctl enable frpc
This will make sure the FRP client and server start up automatically when the system boots up.
You can use systemctl status frps
and systemctl status frpc
to check the status of your services. If you want to see logs, you can use journalctl -u frps
and journalctl -u frpc
.
Remember to replace the placeholders with actual paths to your FRP binaries and config files. The user and group specified here is nobody
, but you might want to change it to a user that suits your security policies better.