Ubuntu20.04进行wikijs搭建

进入wiki官网:https://js.wiki/ 选择【DOCS】-【2.0DOCS】,点击【Installation】选择要安装的系统,当前使用的是linux

根据步骤:

1、下载wikijs

wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz

2、创建解压压缩包

mkdir wiki
tar xzf wiki-js.tar.gz -C ./wiki
cd ./wiki

3、重命名config文件

mv config.sample.yml config.yml

Ubuntu20.04安装PostgreSQL数据库

在Ubuntu下安装Postgresql后,会自动注册为服务,并随操作系统自动启动。
在Ubuntu下安装Postgresql后,会自动添加一个名为postgres的操作系统用户,密码是随机的。并且会自动生成一个名字为postgres的数据库,用户名也为postgres,密码也是随机的。

1. [推荐]apt-get 安装postgres
安装和配置
PostgreSQL 安装 & 用户配置
参考URL: https://blog.csdn.net/inthat/article/details/112168137
安装客户端

apt-get install postgresql-client

安装服务端

apt-get update
apt-get install postgresql

#查看已经安装的postgresql版本
apt show postgresql

上面已经把数据库下载下来了 ,接下来我们 修改默认的postgres数据库用户的密码为123456。

你可以通过执行以下命令来检查 PostgreSQL 是否正在运行:

service postgresql status
root@Ubuntu:/usr/local/wiki# service postgresql status
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Tue 2023-04-18 13:38:20 CST; 1h 15min ago
    Process: 6488 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 6488 (code=exited, status=0/SUCCESS)

4月 18 13:38:20 Ubuntu systemd[1]: Starting PostgreSQL RDBMS...
4月 18 13:38:20 Ubuntu systemd[1]: Finished PostgreSQL RDBMS.
root@Ubuntu:/usr/local/wiki# 

通过 service 命令,你可以启动、关闭或重启 postgresql。输入 service postgresql 并按回车将列出所有选项。现在,登录该用户

默认情况下,PostgreSQL 会创建一个拥有所权限的特殊用户 postgres。要实际使用 PostgreSQL,你必须先登录该账户:

su - postgres

你的提示符会更改为类似于以下的内容:

root@Ubuntu:/usr/local/wiki# su postgres
postgres@Ubuntu:/usr/local/wiki$ 

现在,使用 psql 来启动 PostgreSQL Shell:

root@Ubuntu:/usr/local/wiki# su postgres
postgres@Ubuntu:/usr/local/wiki$ psql
psql (15.2 (Ubuntu 15.2-1.pgdg20.04+1))
输入 "help" 来获取帮助信息.

postgres=# 

你可以输入 \q 以退出,输入 ? 获取帮助。
要查看现有的所有表,输入如下命令:\l

 使用\du可以查看PostgreSQL用户

 改任何用户(包括 postgres)的密码:

ALTER USER postgres WITH PASSWORD 'my_password';
注意:将 postgres 替换为你要更改的用户名,my_password 替换为所需要的密码。另外,不要忘记每条命令后面的;(分号)。

建议你另外创建一个用户(不建议使用默认的 postgres 用户)。为此,请使用以下命令:

CREATE USER wikijs WITH PASSWORD '123456';

运行 \du,你将看到该用户,但是,wikijs用户没有任何的属性。来让我们给它添加超级用户权限:

ALTER USER wikijs WITH SUPERUSER;

你可以使用以下命令删除用户:

DROP USER my_user;

创建数据库,并指定所有者

postgres=# CREATE DATABASE wiki OWNER wikijs;

至此数据库创建完成,使用\q退出,使用su切换至root

Ubuntu20.04 开启远程访问PostgreSQL,安装PostgreSQL数据库之后,默认是只接受本地访问连接。

如果想在其他主机上配置远程连接PostgreSQL,需要修改pg_hba.conf和postgresql.conf

修改pg_hba.conf文件,开通局域网的访问权限,注意IP地址改为自己所在网络的IP。

修改pg_hba.conf文件,配置用户的访问权限

root@sheservice:~# find / -name pg_hba.conf
/etc/postgresql/12/main/pg_hba.conf
root@sheservice:~# vi /etc/postgresql/12/main/pg_hba.conf

一直向下找到local将peer改为trust,保存退出

 至此数据库配置完成

安装nodejs,建议别安装最新版本找个之前较老的版本

使用最新版本nodejs启动wiki服务会报错Package subpath './public/extractFiles'isnot defined by "exports"in /home/xxxxx/wiki/node_modules/extract-files/package.json

root@xxx:/home/xxxxx/wiki# node server
Loading configuration from /home/xxxxx/wiki/config.yml... OK
2022-10-23T05:00:25.563Z [MASTER] info: =======================================
2022-10-23T05:00:25.564Z [MASTER] info: = Wiki.js 2.5.289 =====================
2022-10-23T05:00:25.564Z [MASTER] info: =======================================
2022-10-23T05:00:25.565Z [MASTER] info: Initializing...
2022-10-23T05:00:25.906Z [MASTER] info: Using database driver pg for postgres [ OK ]
2022-10-23T05:00:25.907Z [MASTER] info: Connecting to database...
2022-10-23T05:00:25.945Z [MASTER] info: Database Connection Successful [ OK ]
2022-10-23T05:00:26.276Z [MASTER] warn: Mail is not setup! Please set the configuration in the administration area!
2022-10-23T05:00:26.339Z [MASTER] info: Loading GraphQL Schema...
2022-10-23T05:00:26.703Z [MASTER] error: Package subpath './public/extractFiles' is not defined by "exports" in /home/xxxxx/wiki/node_modules/extract-files/package.json

在nodejs官网:https://nodejs.org/en 选择【Other Download】然后选择最下方第四个【Previous Releases】选择一个较旧的对应的(linux/windows)版本,我当前使用的为15.14.0

 解压、修改文件夹名称

mv node-v15.14.0-linux-x64.tar.gz node

 

配软连接:
相当于全局变量,在任何文件夹都能查看版本信息

ln -s /usr/local/node/bin/node /usr/local/bin/
ln -s /usr/local/node/bin/npm /usr/local/bin/

至此nodejs安装完成,使用node -v可以查看node版本代表安装成功

最后,配置wiki中config.yml文件

 

配置config文件(主要配置数据库)

cd wiki
vim config.yml
将其中的用户名、密码及数据库名称修改为对应创建的名称后:wq保存退出

 使用node server启动wikijs服务

 wikijs搭建完成,使用ip:3000即可访问

 

root@xxx:/home/xxxxx/wiki# node server
Loading configuration from /home/xxxxx/wiki/config.yml... OK
2022-10-23T05:00:25.563Z [MASTER] info: =======================================
2022-10-23T05:00:25.564Z [MASTER] info: = Wiki.js 2.5.289 =====================
2022-10-23T05:00:25.564Z [MASTER] info: =======================================
2022-10-23T05:00:25.565Z [MASTER] info: Initializing...
2022-10-23T05:00:25.906Z [MASTER] info: Using database driver pg for postgres [ OK ]
2022-10-23T05:00:25.907Z [MASTER] info: Connecting to database...
2022-10-23T05:00:25.945Z [MASTER] info: Database Connection Successful [ OK ]
2022-10-23T05:00:26.276Z [MASTER] warn: Mail is not setup! Please set the configuration in the administration area!
2022-10-23T05:00:26.339Z [MASTER] info: Loading GraphQL Schema...
2022-10-23T05:00:26.703Z [MASTER] error: Package subpath './public/extractFiles' is not defined by "exports" in /home/xxxxx/wiki/node_modules/extract-files/package.json
posted @ 2023-04-18 15:31  jokeryy  阅读(384)  评论(0编辑  收藏  举报