一、概要
1. 概念
与Wiki.js类似,Bookstack也是一款知识管理系统(KMS),由PHP实现。在免费开源的KMS中,Bookstack是最像Confluence的一个。
2. 环境
(1) Rocky Linux 9.1
(2) Bookstack 23.02.1
(3) PHP 8.0.27
3. 目录
sudo mkdir -p /opt/BookStack sudo mkdir -p /var/opt/BookStack/logs
二、安装
1. PHP
(1) epel-release
sudo dnf install epel-release -y sudo dnf update -y
(2) php
sudo dnf info php sudo dnf install php -y php -v
(3) php extensions
sudo dnf install -y php-openssl php-pdo php-mbstring php-iconv php-tokenizer php-gd php-mysqlnd php-xml php-dom php-ldap php-fpm
(4) 配置/etc/php.ini
sudo vi /etc/php.ini
按下ESC键,输入
:/cgi.fix_pathinfo
回车。改为:
cgi.fix_pathinfo=0
此外,还可以按需修改以下项目:
date.timezone = Asia/Shanghai ;时区 upload_max_filesize = 60M ;上传单一文件最大Size post_max_size = 200M ;POST请求最大数据量 memory_limit = 512M ;内存用量限制 max_execution_time = 600 ;脚本执行时间上限,单位为秒 max_input_time = 600 ;脚本处理输入数据时间上限,单位为秒; default_socket_timeout = 600 ;Socket链接无回应时长,单位为秒;
2. PHP-FPM
(1) 配置/etc/php-fpm.d/www.conf
sudo vi /etc/php-fpm.d/www.conf
按需修改以下内容:
user = nginx group = nginx listen = /var/run/php-fpm/www.sock listen.owner = nginx listen.group = nginx listen.mode = 0660
移除以下配置行之前的注释符号:
env[HOSTNAME] = $HOSTNAME env[PATH] = /usr/local/bin:/usr/bin:/bin env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp
(2) 启动PHP-FPM
sudo systemctl enable --now php-fpm systemctl status php-fpm
3. PHP Composer
(1) 安装
cd ~/ curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/bin/composer
(2) 测试
composer -V
4. 数据库
(1) 登录MySQL
mysql -u root -p
(2) 数据库
create database if not exists wiki default character set UTF8MB4;
(3) 用户
CREATE USER 'bsuser'@'%' IDENTIFIED BY 'MyNewPass1!'; GRANT ALL PRIVILEGES ON *.* TO 'wiki'@'%' WITH GRANT OPTION; flush privileges;
5. Bookstack
(1) 下载
a. Git下载(需要首先安装Git)
cd /opt/BookStack git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch
b. 源码下载
查找最新版本: https://github.com/BookStackApp/BookStack/releases
cd ~/Download wget https://github.com/BookStackApp/BookStack/archive/refs/tags/v23.02.1.tar.gz
(2) 解压
sudo tar -xvf 23.02.1.tar.gz --strip-components=1 -C /opt/BookStack
(3) 安装
cd /opt/BookStack composer install
6. Nginx
(1) 安装
(2) 授权
sudo chown -R nginx:nginx /opt/BookStack sudo chmod -R 755 /opt/BookStack sudo chown -R nginx:nginx /var/opt/BookStack sudo chmod -R 755 /var/opt/BookStack
三、配置
1. 配置文件
(1) 初始化
cp /opt/BookStack/.env.example /opt/BookStack/.env
(2) 生成应用Key
cd /opt/BookStack php artisan key:generate
2. 数据库
(1) 编辑
vi /opt/BookStack/.env
(2) 配置
DB_HOST=10.8.0.6 DB_DATABASE=bookstack DB_USERNAME=bkuser DB_PASSWORD=MyNewPass1!
(3) 初始化数据库
sudo php artisan migrate
运行之后:
打开数据库,会发现新建了许多表:
3. SELinux
(1) 编辑
sudo vi /etc/sysconfig/selinux
(2) 更新
将SELINUX=enforcing改为:
SELINUX=disabled
(3) 重启
sudo reboot
4. Nginx
假设我们希望使用二级域名bookstack.example.com来访问BookStack程序。
(1) 配置文件
sudo vi /etc/nginx/conf.d/bookstack.conf
(2) 初始化
server { listen 80; server_name bookstack.example.com; root /opt/BookStack/public; index index.php; access_log /var/opt/BookStack/logs/access.log; error_log /var/opt/BookStack/logs/error.log; client_max_body_size 1G; fastcgi_buffers 64 4K; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) { deny all; } location ~ \.php(?:$|/) { fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass unix:/var/run/php-fpm/www.sock; } location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { expires 30d; access_log off; } }
(3) 启动
关闭Selinux
sudo systemctl enable --now nginx systemctl status nginx
4. LDAP
[未完待续]
四、参考
1. 官方
https://www.bookstackapp.com/docs/admin/installation/
https://www.php.net/manual/en/extensions.alphabetical.php
2. 其他
https://www.howtoforge.com/tutorial/centos-bookstack-nginx/
https://dzone.com/articles/how-to-install-bookstack-on-centos-7
https://deviant.engineer/2017/02/bookstack-centos7/
标签:opt,BookStack,Bookstack,sudo,nginx,https,Linux,php,安装 From: https://www.cnblogs.com/eagle6688/p/17249609.html