如何在 Debian 11/Debian 10 上安装 Ghost CMS
本指南将演示如何在 Debian 11/Debian 10 Linux 发行版上安装 Ghost CMS。 Ghost 是一个开源发布平台,设计精美、易于使用,并且对所有人免费。它完全支持 Markdown,并提供易于使用的网络界面来进行管理。
对于 CentOS/RHEL:在 CentOS/RHEL 7/8 上安装和配置 Ghost CMS
设置要求
对于此设置,基本要求是:
- Debian 11/Debian 10 Linux 服务器
- Nginx 网络服务器
- FQDN – 例如 blog.example.com(有指向您的服务器 FQDN 的 DNS A 记录)
- 安装了 Node.js
- MySQL/MariaDB 数据库服务器
- Ghost 用户 – 非 root 用户来管理它
让我们开始在 Debian 11/Debian 10 Linux 机器上安装 Ghost。
第1步:安装并配置MySQL/MariaDB数据库服务器
为 Ghost CMS 安装数据库服务器。这可以是 MySQL 或 MariaDB 数据库服务器。
sudo apt update
sudo apt install mariadb-server
完成后,为您计划添加的 Ghost 博客创建数据库:
$ sudo mysql -u root -p
CREATE USER ghostcms@localhost IDENTIFIED BY "StrongDBPassword";
CREATE DATABASE ghostcms;
GRANT ALL ON ghostcms.* TO ghostcms@localhost;
FLUSH PRIVILEGES;
QUIT
步骤 2:在 Debian 上安装 Nginx Web 服务器
接下来是Nginx的安装
sudo apt -y install nginx
Nginx systemd 服务安装后自动启动:
$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-03-21 20:01:19 UTC; 31s ago
Docs: man:nginx(8)
Process: 3565 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3566 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3755 (nginx)
Tasks: 3 (limit: 2340)
Memory: 4.4M
CPU: 23ms
CGroup: /system.slice/nginx.service
├─3755 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─3758 nginx: worker process
└─3759 nginx: worker process
Mar 21 20:01:19 debian-bullseye-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 21 20:01:19 debian-bullseye-01 systemd[1]: Started A high performance web server and a reverse proxy server.
步骤 3:添加 Ghost 管理用户
添加名为 ghostadmin
的用户
sudo adduser ghostadmin
sudo usermod -aG sudo ghostadmin
步骤 4:在 Debian 11/10 上安装 Node.js
配置 Node.js 16 apt 存储库。
sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
配置存储库后,在 Debian 上安装 Node.js:
sudo apt install -y nodejs
确认节点版本
$ node -v
v16.14.2
步骤 5:在 Debian 11/Debian 10 上安装 Ghost-CLI
我们现在需要安装提供ghost命令的包ghost-cli。
sudo npm i -g ghost-cli
步骤 6:为 Ghost Data 创建一个新文件夹
请注意:
- 在/root文件夹中安装 Ghost 将不起作用并导致设置损坏!
- 在您的 /home/{user} 文件夹中安装 Ghost 将不起作用并导致设置损坏!
- 请仅使用/var/www/{folder},因为它具有正确的权限。
那么让我们创建这个目录:
sudo mkdir -p /var/www/ghost
sudo chown ghostadmin:ghostadmin /var/www/ghost
sudo chmod 775 /var/www/ghost
第 7 步:在 Debian 11/Debian 10 上安装 Ghost
创建 Ghost CMS 目录。
sudo su - ghostadmin
cd /var/www/ghost
mkdir blog.example.com
cd blog.example.com
运行以下命令安装 Ghost:
$ ghost install
Checking system Node.js version
Checking logged in user
Checking current folder permissions
Checking operating system compatibility
Checking for a MySQL installation
Checking memory availability
Checking for latest Ghost version
Setting up install directory
Downloading and installing Ghost v4.41.0
Finishing install process
? Enter your blog URL: http://blog.example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostcms
? Enter your MySQL password: [hidden] StrongDBPassword
? Enter your Ghost database name: ghostcms
Configuring Ghost
Setting up instance
sudo useradd --system --user-group ghost
sudo chown -R ghost:ghost /var/www/ghost/blog.example.com/content
Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes
MySQL user is not "root", skipping additional user setup
Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
Creating nginx config file at /var/www/ghost/blog.example.com/system/files/blog.example.com.conf
sudo ln -sf /var/www/ghost/blog.example.com/system/files/blog.example.com.conf /etc/nginx/sites-available/blog.example.com.conf
sudo ln -sf /etc/nginx/sites-available/blog.example.com.conf /etc/nginx/sites-enabled/blog.example.com.conf
sudo nginx -s reload
Setting up Nginx
? Do you wish to set up SSL? No
Setting up SSL [skipped]
? Do you wish to set up Systemd? Yes
Creating systemd service file at /var/www/ghost/blog.example.com/system/files/ghost_blog-example-com.service
sudo ln -sf /var/www/ghost/blog.example.com/system/files/ghost_blog-example-com.service /lib/systemd/system/ghost_blog-example-com.service
sudo systemctl daemon-reload
Setting up Systemd
? Do you want to start Ghost? Yes
sudo systemctl is-active ghost_blog-example-com
Ensuring user is not logged in as ghost user
Checking if logged in user is directory owner
Checking current folder permissions
sudo systemctl is-active ghost_blog-example-com
Validating config
Checking folder permissions
Checking file permissions
Checking content folder ownership
Checking memory availability
sudo systemctl start ghost_blog-example-com
Starting Ghost
sudo systemctl is-enabled ghost_blog-example-com
sudo systemctl enable ghost_blog-example-com --quiet
Enabling Ghost instance startup on server boot
Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/mail
Ghost was installed successfully! To complete setup of your publication, visit:
http://blog.example.com/ghost/
这将使用 MySQL 作为默认数据库以生产模式安装并启动您的博客。您可以同意
设置 Let's Encrypt SSL
。如果您的服务器有有效的域名和公共 IP 地址。
Nginx 配置文件将放置在:/etc/nginx/sites-enabled/ 下
检查服务状态:
$ systemctl status ghost_blog-example-com
● ghost_blog-example-com.service - Ghost systemd service for blog: blog-example-com
Loaded: loaded (/var/www/ghost/blog.example.com/system/files/ghost_blog-example-com.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-01-30 17:06:48 EAT; 34min ago
Docs: https://docs.ghost.org
Main PID: 19723 (ghost run)
Tasks: 18 (limit: 4915)
CGroup: /system.slice/ghost_blog-example-com.service
├─19723 ghost run
└─19734 /usr/bin/node current/index.js
幽灵秘籍:
日志目录:/content/logs/
$Ghost start:启动 Ghost
$Ghost restart:重新启动 Ghost
$ghost run:测试ghost是否能够成功启动
$ghost uninstall:重新安装ghost
$ghost update:升级ghost
$ghost update --force:如果出现错误则强制升级
$ghost update --rollback:如果升级失败则恢复到早期版本< br>$sudo npm i -g Ghost-cli@latest:升级 Ghost-CLI
$Ghost ssl-renew:续订 ssl 证书
$ls ./system/files/*.conf:系统配置文件
$Ghost setup nginx:手动设置nginx
$Ghost setup nginx ssl:使用 SSL 设置 nginx
在 Debian 11/Debian 10 上访问 Ghost 管理界面
您的设置现已准备就绪,访问 Ghost Web 管理界面,您可以在其中上传主题、更改设置并使用 Markdown 语法编写内容。
要完成出版物的设置,请访问:
创建您的第一个 Ghost 管理员/发布者帐户。
您已在 Debian 11/Debian 10 上成功安装 Ghost CMS。另请参阅有关 Web 托管和文档的其他指南。
最佳商业虚拟主机控制面板 – Cpanel 替代品
最佳免费开源虚拟主机控制面板
NextCloud、ownCloud、Seafile、Syncthing
Ceph、GlusterFS、MooseFS、HDFS、DRBD