功能类似于 Set up MediaWiki with PHP7.4, nginx and MySQLWiki.js – 自托管百科/文档管理系统

下文为无域名搭建方式

环境

  • Debian 11
    • LNMP
    • PHP-Composer

参考

步骤

准备 LNMP 环境

安装 Nginx、PHP 及其组件

apt install nginx php7.4 php7.4-fpm php7.4-curl php7.4-gd php7.4-xml php7.4-zip php7.4-mysql unzip

安装 PHP-Composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

mv composer.phar /usr/local/bin/composer

安装 MySQL

wget https://repo.mysql.com//mysql-apt-config_0.8.22-1_all.deb
dpkg -i mysql-apt-config_0.8.22-1_all.deb
apt update
apt install mysql-community-server

安装 PHP 后会自动安装 Apache,导致 Nginx 无法启动,所以先卸载 Apache

apt remove apache2

新建数据库

登录 MySQL

mysql -u root -p
# 输入密码

新建 BookStack 数据库及其用户

CREATE DATABASE BookStack;
CREATE USER 'bs'@'localhost' IDENTIFIED BY 'veryStrongPassword';
GRANT ALL PRIVILEGES ON BookStack.* TO 'bs'@'localhost';
exit;

新建 Nginx 配置文件

官方提供的 Nginx 配置文件会将 BookStack 托管在子目录,即 domain.com/bookstack

如果需要托管在根目录,对更改官方配置文件稍加更改即可

在 /etc/nginx/sites-available 下新建配置文件 bookstack,写入以下内容

server {
  listen 80;

  server_name [IP];

  root /var/www/BookStack/public;
  index index.php index.html;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  }
}

新建软链接

ln -s /etc/nginx/sites-available/bookstack /etc/nginx/sites-enabled

获取并安装 BookStack

Continue reading “BookStack – 自托管文档管理/Wiki系统”