如何在 Ubuntu 18.04 LTS 上使用 NGINX 安装 Bludit CMS
在此页
- 要求
- 先决条件
- 第 1 步 - 安装 PHP
- 第 2 步 - 安装 Acme.sh 客户端并获取 Lets Encrypt 证书(可选)
- 第 3 步 - 安装和配置 NGINX
- 第 4 步 - 安装 Bludit
- 第 5 步 - 完成 Bludit 安装向导
- 链接
Bludit 是一种简单、快速、安全的平面文件 CMS,可让您在几秒钟内创建自己的网站或博客。它完全免费和开源。你可以在 Github 上浏览它的源代码。 Bludit 使用 JSON 格式的文件来存储内容,你不需要安装或配置数据库。您只需要一个支持 PHP 的 Web 服务器。 Bludit 整合了所有 SEO 工具来提高您在所有搜索引擎和社交网络中的排名。它具有丰富的主题和插件系统,您可以使用它们来更改站点的外观。在本教程中,我们将使用 NGINX 作为网络服务器,在 Ubuntu 18.04 LTS 系统上安装和设置 Bludit CMS。
要求
确保您的系统满足以下要求:
- PHP 版本 5.3 或更高版本,具有以下扩展名:
mbstring,
gd,
dom,
json
- 一个支持 PHP 的网络服务器,例如 Nginx、Apache、Lighttpd、H2O。本教程将使用 NGINX。
先决条件
- 运行 Ubuntu 18.04 LTS 的操作系统。
- 具有 sudo 权限的非根用户。
初始步骤
检查您的 Ubuntu 版本:
lsb_release -ds
# Ubuntu 18.04.1 LTS
设置时区:
sudo dpkg-reconfigure tzdata
更新您的操作系统包(软件)。这是重要的第一步,因为它确保您拥有操作系统默认软件包的最新更新和安全修复程序:
sudo apt update && sudo apt upgrade -y
安装 Ubuntu 操作系统基本管理所需的一些基本软件包:
sudo apt install -y curl wget vim git unzip socat bash-completion
第 1 步 - 安装 PHP
安装 PHP 以及必要的 PHP 扩展:
sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-zip php7.2-pgsql php7.2-sqlite3 php7.2-curl php7.2-gd php7.2-mysql php7.2-intl php7.2-json php7.2-opcache php7.2-xml
要显示在模块中编译的 PHP,您可以运行:
php -m
ctype
curl
exif
fileinfo
. . .
. . .
检查 PHP 版本:
php --version
# PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb 8 2019 14:54:22) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.15-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
PHP-FPM服务在Ubuntu 18.04系统重启时自动启动启用,无需手动启动启用。我们可以继续下一步,即数据库安装和设置。
第 2 步 - 安装 Acme.sh 客户端并获取 Lets Encrypt 证书(可选)
没有必要使用 HTTPS 保护您的网站,但这是保护您的网站流量的好习惯。为了从 Lets Encrypt 获得 TLS 证书,我们将使用 acme.sh 客户端。 Acme.sh 是一个纯 Unix shell 软件,用于以零依赖从 Lets Encrypt 获取 TLS 证书。
下载并安装 acme.sh:
sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail
source ~/.bashrc
cd ~
检查 acme.sh 版本:
acme.sh --version
# v2.8.1
为您的域/主机名获取 RSA 和 ECC/ECDSA 证书:<br>
# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256
如果你想要伪造的证书进行测试,你可以在上面的命令中添加 --staging
标志。
运行上述命令后,您的证书和密钥将位于:
- 对于 RSA:
/home/username/example.com
目录。 - 对于 ECC/ECDSA:
/home/username/example.com_ecc
目录。
要列出您颁发的证书,您可以运行:
acme.sh --list
创建一个目录来存储您的证书。我们将使用目录 /etc/letsencrypt.
mkdir -p /etc/letsencrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc
安装/复制证书到 /etc/letsencrypt 目录。
# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
所有证书将每 60 天自动更新一次。
获得证书后,从 root 用户退出并返回到普通 sudo 用户:
exit
第 3 步 - 安装和配置 NGINX
从 Ubuntu 存储库下载并安装 NGINX:
sudo apt install -y nginx
检查 NGINX 版本:
sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)
运行 sudo vim /etc/nginx/sites-available/bludit.conf
并为 Bludit 配置 NGINX。
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
server_name example.com;
root /var/www/bludit;
index index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ^~ /bl-content/tmp/ { deny all; }
location ^~ /bl-content/pages/ { deny all; }
location ^~ /bl-content/databases/ { deny all; }
}
通过将文件链接到 sites-enabled
目录来激活新的 bludit.conf
配置:
sudo ln -s /etc/nginx/sites-available/bludit.conf /etc/nginx/sites-enabled/
测试 NGINX 配置:
sudo nginx -t
重新加载 NGINX:
sudo systemctl reload nginx.service
第 4 步 - 安装 Bludit
创建 Bludit 应位于的文档根目录:
sudo mkdir -p /var/www/bludit
将 /var/www/bludit
目录的所有权更改为 {jour_user}:
sudo chown -R {your_user}:{your_user} /var/www/bludit
导航到文档根目录:
cd /var/www/bludit
从官方页面下载最新版本并解压缩 zip 文件:
wget https://www.bludit.com/releases/bludit-3-8-1.zip
unzip bludit-3-8-1.zip
rm bludit-3-8-1.zip
mv bludit-3-8-1/* . && mv bludit-3-8-1/.* .
rmdir bludit-3-8-1
注意:如果有更新的版本,请更新下载 URL。
将 /var/www/bludit
目录的所有权更改为 www-data:
sudo chown -R www-data:www-data /var/www/bludit
第 5 步 - 完成 Bludit 安装向导
在网络浏览器中打开您的网站。在网络浏览器中打开您的网站后,您应该被重定向到以下页面,以选择您的语言:

接下来,为用户 admin 创建一个密码,然后单击“安装”:

创建管理员密码后,您将被重定向到 Bludit 前端:

要访问 Bludit 管理区域,请将 /admin
附加到您的站点 IP 或 URL。这就是 Bludit 管理员的样子:

安装完成。使用 Bludit CMS 快乐地写博客。
链接
- <李>
- https://plugins.bludit.com/
- https://themes.bludit.com/
- https://github.com/bludit/bludit