在Arch Linux上使用Makepkg
在Arch Linux上使用Makepkg可以避免系统污染,确保仅安装必要的依赖关系。
Wiki.js是基于Node.js,MongoDB,Git和Markdown构建的免费,开源的现代Wiki应用程序。Wiki.js源代码公开托管在GitHub上。本指南将向您展示如何通过使用Node.js,MongoDB,PM2,Nginx,Git和Acme.sh在新的Debian 9 Vultr实例上安装Wiki.js。
768MB RAM
A
/ AAAA
记录的域名检查Debian版本。
lsb_release -ds
# Debian GNU/Linux 9.4 (stretch)
确保您的系统是最新的。
apt update && apt upgrade -y
安装必要的软件包。
apt install -y build-essential apt-transport-https sudo curl wget dirmngr sudo
创建一个non-root
具有sudo
访问权限的新用户帐户并切换到该帐户。
adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe
注意:用您的用户名替换johndoe
。
设置时区。
sudo dpkg-reconfigure tzdata
在Debian上安装Git。
sudo apt install -y git
验证Git版本。
git --version
# git version 2.11.0
利用Node.js的NodeSource APT存储库安装Node.js。
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt install -y nodejs
检查Node.js和npm版本。
node -v && npm -v
# v8.11.2
# 5.6.0
Wiki.js使用MongoDB作为数据库引擎。据此,我们将需要在服务器上安装MongoDB。我们将使用官方的MongoDB存储库进行安装。
安装MongoDB社区版。
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt update
sudo apt install -y mongodb-org
检查版本。
mongo --version | head -n 1 && mongod --version | head -n 1
# MongoDB shell version v3.6.5
# db version v3.6.5
启用并启动MongoDB。
sudo systemctl enable mongod.service
sudo systemctl start mongod.service
强烈建议在Wiki.js前面放置一个标准的Web服务器。这样可以确保您可以使用SSL,多个网站,缓存等功能。在本教程中,我们将使用Nginx,但是任何其他服务器都可以使用,您只需要正确配置它即可。
安装Nginx。
wget https://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
rm nginx_signing.key
sudo -s
printf "deb https://nginx.org/packages/mainline/debian/ $(lsb_release -sc) nginx\ndeb-src https://nginx.org/packages/mainline/debian/ $(lsb_release -sc) nginx\n" >> /etc/apt/sources.list.d/nginx_mainline.list
exit
sudo apt update
sudo apt install -y nginx
检查版本。
sudo nginx -v
# nginx version: nginx/1.15.0
启用并启动Nginx。
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
将Nginx配置为Wiki.js应用程序的反向代理HTTP
或HTTPS
(如果使用SSL,则)反向代理。
运行sudo vim /etc/nginx/conf.d/wiki.js.conf
并使用下面的基本反向代理配置填充它。
server {
listen [::]:80;
listen 80;
server_name wiki.example.com;
root /usr/share/nginx/html;
charset utf-8;
client_max_body_size 50M;
location /.well-known/acme-challenge/ {
allow all;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_next_upstream error timeout http_502 http_503 http_504;
}
}
在上述配置中,您唯一需要更改的就是server_name
指令,proxy_pass
如果您决定配置以外的其他端口,则可能需要更改指令3000
。Wiki.js 3000
默认使用端口。
检查配置。
sudo nginx -t
重新加载Nginx。
sudo systemctl reload nginx.service
HTTPS
不必使用Wiki保护您的Wiki ,但这是确保您的网站访问量的一个好习惯。为了从Let's Encrypt获得SSL证书,我们将使用Acme.sh客户端。Acme.sh是一个纯unix shell软件,用于以零依赖关系从Let's Encrypt获得SSL证书。与其他一些需要大量依赖才能成功运行的ACME协议客户端相比,它非常轻巧。
下载并安装Acme.sh。
sudo mkdir /etc/letsencrypt
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
sudo ./acme.sh --install --home /etc/letsencrypt --accountemail [email protected]
cd ~
检查版本。
/etc/letsencrypt/acme.sh --version
# v2.7.9
获得RSA和ECDSA证书wiki.example.com
。
# RSA 2048
sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt -d wiki.example.com --webroot /usr/share/nginx/html --reloadcmd "sudo systemctl reload nginx.service" --accountemail [email protected] --ocsp-must-staple --keylength 2048
# ECDSA/ECC P-256
sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt -d wiki.example.com --webroot /usr/share/nginx/html --reloadcmd "sudo systemctl reload nginx.service" --accountemail [email protected] --ocsp-must-staple --keylength ec-256
注意:不要忘记wiki.example.com
用您的域名替换。
运行上述命令后,您的证书和密钥将位于以下目录中。
/etc/letsencrypt/wiki.example.com
目录。/etc/letsencrypt/wiki.example.com_ecc
目录。从Let's Encrypt获得证书后,我们需要配置Nginx来利用它们。
sudo vim /etc/nginx/conf.d/wiki.js.conf
再次运行,并将Nginx配置为HTTPS
反向代理。
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;
server_name wiki.example.com;
root /usr/share/nginx/html;
charset utf-8;
client_max_body_size 50M;
location /.well-known/acme-challenge/ {
allow all;
}
# RSA
ssl_certificate /etc/letsencrypt/wiki.example.com/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/wiki.example.com/example.com.key;
# ECDSA
ssl_certificate /etc/letsencrypt/wiki.example.com_ecc/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/wiki.example.com_ecc/example.com.key;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_next_upstream error timeout http_502 http_503 http_504;
}
}
检查配置。
sudo nginx -t
重新加载Nginx。
sudo systemctl reload nginx.service
在应该安装Wiki.js的地方创建一个空的文档根文件夹。
sudo mkdir -p /var/www/wiki.example.com
导航到文档根文件夹。
cd /var/www/wiki.example.com
将/var/www/wiki.example.com
文件夹的所有权更改为user johndoe
。
sudo chown -R johndoe:johndoe /var/www/wiki.example.com
在该/var/www/wiki.example.com
文件夹中,运行以下命令以下载并安装Wiki.js。
curl -sSo- https://wiki.js.org/install.sh | bash
您可以运行以下命令以查看Wiki.js的当前安装版本。
node wiki --version
# 1.0.78
安装完成后,系统将提示您运行配置向导。
通过运行启动配置向导。
node wiki configure
这将通知您导航http://localhost:3000
以配置Wiki.js。如果您在Wiki.js前面有Nginx,则意味着您可以打开域名(例如http://wiki.example.com
),而不必转到localhost
。
使用网络浏览器,浏览http://wiki.example.com
并遵循屏幕上的说明。在配置向导中输入的所有设置都保存在config.yml
文件中。配置向导将自动为您启动Wiki.js。
默认情况下,Wiki.js在系统重启后不会自动启动。为了使其在启动时启动,我们需要设置PM2进程管理器。PM2与Wiki.js捆绑在一起作为本地NPM模块,因此我们无需在全球范围内安装PM2。
告诉PM2将其自身配置为启动服务。
/var/www/wiki.example.com/node_modules/pm2/bin/pm2 startup
最后,保存当前的PM2配置。
/var/www/wiki.example.com/node_modules/pm2/bin/pm2 save
您的Wiki.js实例使用PM2作为其进程管理器,作为后台进程运行。您可以使用重新启动操作系统,sudo reboot
并检查重新启动后Wiki.js是否启动。
在Arch Linux上使用Makepkg可以避免系统污染,确保仅安装必要的依赖关系。
快速学习如何在Ubuntu 16.04上安装OpenSIPS控制面板,为VoIP提供商提供支持的功能。
学习如何在Fedora 28上安装Akaunting,一款适合小型企业和自由职业者的开源会计软件。
使用其他系统?Mailtrain是一个基于Node.js和MySQL / MariaDB构建的开源自托管新闻通讯应用程序。
了解導致Minecraft延遲的原因和解決方案,包括優化伺服器性能和減少滯後的步驟。
勒索軟件攻擊呈上升趨勢,但人工智能能否幫助應對最新的計算機病毒?AI 是答案嗎?在這裡閱讀知道是 AI 布恩還是禍根
ReactOS,一個開源和免費的操作系統,這裡有最新版本。它能否滿足現代 Windows 用戶的需求並打倒微軟?讓我們更多地了解這種老式但更新的操作系統體驗。
Whatsapp 終於為 Mac 和 Windows 用戶推出了桌面應用程序。現在您可以輕鬆地從 Windows 或 Mac 訪問 Whatsapp。適用於 Windows 8+ 和 Mac OS 10.9+
閱讀本文以了解人工智能如何在小型公司中變得流行,以及它如何增加使它們成長並為競爭對手提供優勢的可能性。
最近,Apple 發布了 macOS Catalina 10.15.4 補充更新以修復問題,但似乎該更新引起了更多問題,導致 mac 機器變磚。閱讀這篇文章以了解更多信息