Browse Source

Linux: add basic instructions to run SFTPGo as service

Nicola Murino 5 năm trước cách đây
mục cha
commit
61f20f5449
1 tập tin đã thay đổi với 38 bổ sung4 xóa
  1. 38 4
      docs/service.md

+ 38 - 4
docs/service.md

@@ -4,6 +4,39 @@
 
 For Linux, a `systemd` sample [service](../init/sftpgo.service "systemd service") can be found inside the source tree.
 
+Here are some basic instructions to run SFTPGo as service, please run the following commands from the directory where you downloaded SFTPGo:
+
+```bash
+# create the required directories
+sudo mkdir -p /etc/sftpgo \
+  /var/lib/sftpgo
+
+# install sftpgo executable
+sudo install -Dm755 sftpgo /usr/bin/sftpgo
+# install the default configuration file, edit it if required
+sudo install -Dm644 sftpgo.json /etc/sftpgo/
+# override some configuration keys using environment variables
+sudo echo "SFTPGO_HTTPD__TEMPLATES_PATH=/var/lib/sftpgo/templates" > /etc/sftpgo/sftpgo.env
+sudo echo "SFTPGO_HTTPD__STATIC_FILES_PATH=/var/lib/sftpgo/static" >> /etc/sftpgo/sftpgo.env
+sudo echo "SFTPGO_HTTPD__BACKUPS_PATH=/var/lib/sftpgo/backups" >> /etc/sftpgo/sftpgo.env
+sudo echo "SFTPGO_DATA_PROVIDER__CREDENTIALS_PATH=/var/lib/sftpgo/credentials" >> /etc/sftpgo/sftpgo.env
+# install static files and templates for the web UI
+sudo cp -r static templates /var/lib/sftpgo/
+# initialize the configured data provider
+# if you want to use MySQL or PostgreSQL you need to create the configured database before running the initprovider command
+sudo /usr/bin/sftpgo initprovider -c /etc/sftpgo/
+# install the systemd service
+sudo install -Dm644 init/sftpgo.service /etc/systemd/system
+# start the service
+sudo systemctl start sftpgo
+# verify that the service is started
+sudo systemctl status sftpgo
+# automatically start sftpgo on boot
+sudo systemctl enable sftpgo
+# optional, install the REST API CLI. It requires python-requests to run
+sudo install -Dm755 scripts/sftpgo_api_cli.py /usr/bin/sftpgo_api_cli
+```
+
 ## macOS
 
 For macOS, a `launchd` sample [service](../init/com.github.drakkan.sftpgo.plist "launchd plist") can be found inside the source tree. The `launchd` plist assumes that SFTPGo has `/usr/local/opt/sftpgo` as base directory.
@@ -21,16 +54,17 @@ sudo mkdir -p /usr/local/opt/sftpgo/init \
 # install sftpgo executable
 sudo cp sftpgo /usr/local/opt/sftpgo/bin/
 # install the launchd service
-sudo cp init/com.github.drakkan.sftpgo.plist /usr/local/opt/sftpgo/init
+sudo cp init/com.github.drakkan.sftpgo.plist /usr/local/opt/sftpgo/init/
 # install the default configuration file, edit it if required
 sudo cp sftpgo.json /usr/local/opt/sftpgo/etc/
-# install static file and templates for the web UI
+# install static files and templates for the web UI
 sudo cp -r static templates /usr/local/opt/sftpgo/var/lib/
 # initialize the configured data provider
-sudo /usr/local/opt/sftpgo/bin/sftpgo initprovider -c /usr/local/opt/sftpgo/etc
+# if you want to use MySQL or PostgreSQL you need to create the configured database before running the initprovider command
+sudo /usr/local/opt/sftpgo/bin/sftpgo initprovider -c /usr/local/opt/sftpgo/etc/
 # add sftpgo to the launch daemons
 sudo ln -s /usr/local/opt/sftpgo/init/com.github.drakkan.sftpgo.plist /Library/LaunchDaemons/com.github.drakkan.sftpgo.plist
-# start the service
+# start the service and enable it to start on boot
 sudo launchctl load -w /Library/LaunchDaemons/com.github.drakkan.sftpgo.plist
 # verify that the service is started
 sudo launchctl list com.github.drakkan.sftpgo