DEV Community

Simon
Simon

Posted on

Ubuntu 上安装和配置 PocketBase 指南

安装步骤

  1. 下载 PocketBase:
   wget https://github.com/pocketbase/pocketbase/releases/download/v0.x.x/pocketbase_0.x.x_linux_amd64.zip
Enter fullscreen mode Exit fullscreen mode

注意:将 0.x.x 替换为最新的版本号。我安装的最新版本为 0.22.20

  1. 解压文件:
   unzip pocketbase_0.x.x_linux_amd64.zip
Enter fullscreen mode Exit fullscreen mode
  1. 移动到适当的目录:
   sudo mv pocketbase /usr/local/bin/
Enter fullscreen mode Exit fullscreen mode
  1. 设置执行权限:
   sudo chmod +x /usr/local/bin/pocketbase
Enter fullscreen mode Exit fullscreen mode
  1. 创建数据目录:
   sudo mkdir /var/pocketbase
Enter fullscreen mode Exit fullscreen mode
  1. 创建系统服务文件:
   sudo nano /etc/systemd/system/pocketbase.service
Enter fullscreen mode Exit fullscreen mode

在文件中添加以下内容:

   [Unit]
   Description=PocketBase service
   After=network.target

   [Service]
   Type=simple
   User=root
   ExecStart=/usr/local/bin/pocketbase serve --http="0.0.0.0:8090" --dir="/var/pocketbase"
   Restart=on-failure

   [Install]
   WantedBy=multi-user.target
Enter fullscreen mode Exit fullscreen mode
  1. 重新加载 systemd:
   sudo systemctl daemon-reload
Enter fullscreen mode Exit fullscreen mode
  1. 启动 PocketBase 服务:
   sudo systemctl start pocketbase
Enter fullscreen mode Exit fullscreen mode
  1. 设置开机自启:
   sudo systemctl enable pocketbase
Enter fullscreen mode Exit fullscreen mode
  1. 检查服务状态:

    sudo systemctl status pocketbase
    

现在,PocketBase 应该已经在您的 Ubuntu 系统上运行,并监听在 8090 端口。您可以通过访问 http://your_server_ip:8090/_/ 来访问 PocketBase 的管理界面。

Top comments (0)