如何在 Debian 上安装 BookStack 12

Linux命令 Edge插件网 1年前 (2023-11-06) 275次浏览 已收录 0个评论

BookStack 是一个功能强大的开源平台,旨在组织和存储信息、笔记和文档。如果您希望使用命令行界面 (CLI) 在 Debian 12 服务器上设置 BookStack,那么您来对地方了。

如何在 Debian 上安装 BookStack 12

在 Debian 上安装 BookStack 12 Bookworm

步骤 1。首先更新系统的软件包列表,并将已安装的软件包升级到最新版本。使用以下命令:

<span class="pln">sudo apt update
sudo apt upgrade</span>

此命令更新软件包列表,并将已安装的软件包升级到最新版本。

第2步。安装 LAMP 堆栈。

在安装 BookStack 之前,您需要在 Debian 服务器上设置一个 LAMP(Linux、Apache、MariaDB、PHP)堆栈。

第 3 步。配置 MariaDB。

在下一步中,您将使用该实用程序配置 MariaDB 服务器安装,该实用程序允许您为 MariaDB 设置基本安全性:mariadb-secure-installation

<span class="pln">sudo mysql_secure_installation</span>

按照屏幕上的提示设置 root 密码、删除匿名用户、禁止远程 root 登录以及删除测试数据库。

通过运行以下命令为 BookStack 创建专用数据库和用户:

<span class="pln">mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>

输入您的 root 密码,然后执行以下 SQL 命令:

<span class="pln">CREATE DATABASE bookstack</span><span class="pun">;</span><span class="pln">
CREATE USER </span><span class="str">'bookstack'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your_strong_password'</span><span class="pun">;</span><span class="pln">
GRANT ALL PRIVILEGES ON bookstack</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'bookstack'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pun">;</span><span class="pln">
FLUSH PRIVILEGES</span><span class="pun">;</span><span class="pln">
EXIT</span><span class="pun">;</span>

第 4 步。安装 Composer。

Composer 是 PHP 的依赖管理工具,我们将使用它来安装和管理 BookStack。使用以下命令安装 Composer:

<span class="pln">php </span><span class="pun">-</span><span class="pln">r </span><span class="str">"copy('https://getcomposer.org/installer', 'composer-setup.php');"</span><span class="pln">
php composer</span><span class="pun">-</span><span class="pln">setup</span><span class="pun">.</span><span class="pln">php </span><span class="pun">--</span><span class="pln">install</span><span class="pun">-</span><span class="pln">dir</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin </span><span class="pun">--</span><span class="pln">filename</span><span class="pun">=</span><span class="pln">composer
php </span><span class="pun">-</span><span class="pln">r </span><span class="str">"unlink('composer-setup.php');"</span>

第 5 步。在 Debian 12 上安装 BookStack。

现在从 GitHub 克隆 BookStack 存储库:

<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html
sudo git clone https</span><span class="pun">:</span><span class="com">//github.com/BookStackApp/BookStack.git</span>

移动到 BookStack 目录并配置环境:

<span class="pln">cd </span><span class="typ">BookStack</span><span class="pln">
cp </span><span class="pun">.</span><span class="pln">env</span><span class="pun">.</span><span class="pln">example </span><span class="pun">.</span><span class="pln">env</span>

使用您喜欢的文本编辑器编辑文件:.env

<span class="pln">sudo nano </span><span class="pun">.</span><span class="pln">env</span>

使用您的 MariaDB 凭据更新以下设置:

<span class="pln">DB_DATABASE</span><span class="pun">=</span><span class="pln">bookstack
DB_USERNAME</span><span class="pun">=</span><span class="pln">bookstack
DB_PASSWORD</span><span class="pun">=</span><span class="pln">your_strong_password</span>

保存并退出文本编辑器,然后使用 Composer 安装所需的依赖项:

<span class="pln">composer install</span>

生成应用程序密钥并迁移数据库:

<span class="pln">php artisan key</span><span class="pun">:</span><span class="pln">generate
php artisan migrate</span>

通过运行以下命令初始化 BookStack:

<span class="pln">php artisan bookstack</span><span class="pun">:</span><span class="pln">install</span>

按照提示配置您的 BookStack 实例,包括设置管理员帐户和指定您的首选电子邮件设置。

第 6 步。配置 Apache 虚拟主机。

为 BookStack 创建一个新的 Apache 虚拟主机配置文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache2</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">bookstack</span><span class="pun">.</span><span class="pln">conf</span>

添加以下内容,根据需要调整路径:

<span class="tag"><VirtualHost</span><span class="pln"> *:80</span><span class="tag">></span><span class="pln">
ServerName your_domain_or_IP
DocumentRoot /var/www/html/BookStack/public
</span><span class="tag"><Directory</span> <span class="pun">/</span><span class="atn">var</span><span class="pun">/</span><span class="atn">www</span><span class="pun">/</span><span class="atn">html</span><span class="pun">/</span><span class="atn">BookStack</span><span class="pun">/</span><span class="atn">public</span><span class="tag">></span><span class="pln">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</span><span class="tag"></Directory></span>
<span class="tag"></VirtualHost></span>

保存并退出文本编辑器,然后启用新的虚拟主机并重新启动 Apache:

<span class="pln">sudo a2ensite bookstack</span><span class="pun">.</span><span class="pln">conf
sudo systemctl restart apache2</span>

第 7 步。设置 Let’s Encrypt for SSL。

要使用 SSL 保护您的 BookStack 实例,我们建议使用 Let’s Encrypt。安装 Certbot 并获取 SSL 证书:

<span class="pln">sudo apt install certbot python3</span><span class="pun">-</span><span class="pln">certbot</span><span class="pun">-</span><span class="pln">apache
sudo certbot </span><span class="pun">--</span><span class="pln">apache</span>

第 8 步。设置 cron 作业。

BookStack 需要定期任务来保持最佳性能。创建一个 cron 作业以自动执行这些任务:

<span class="pln">sudo crontab </span><span class="pun">-</span><span class="pln">u www</span><span class="pun">-</span><span class="pln">data </span><span class="pun">-</span><span class="pln">e</span>

将以下行添加到 crontab 文件中:

<span class="pun">*</span> <span class="pun">*</span> <span class="pun">*</span> <span class="pun">*</span> <span class="pun">*</span><span class="pln"> php </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="typ">BookStack</span><span class="pun">/</span><span class="pln">artisan schedule</span><span class="pun">:</span><span class="pln">run </span><span class="pun">>></span> <span class="str">/dev/</span><span class="kwd">null</span> <span class="lit">2</span><span class="pun">>&</span><span class="lit">1</span>

保存并退出文本编辑器。

第 9 步。访问 BookStack Web 界面。

打开 Web 浏览器并导航到 BookStack 站点 ()。您应该会看到 BookStack 登录页面。使用您在安装过程中创建的管理员帐户登录。https://your_domain_or_IP

如何在 Debian 上安装 BookStack 12

感谢您使用本教程在 Debian 12 Bookworm 上安装最新版本的 BookStack。如需更多帮助或有用信息,我们建议您查看 BookStack 官方网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Debian 上安装 BookStack 12
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址