如何在Linux上安装Ghost博客平台如何在Linux上安装Ghost博客平台如何在Linux上安装Ghost博客平台如何在Linux上安装Ghost博客平台
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在Linux上安装Ghost博客平台

在本教程中,我将描述如何在 Linux 上设置 Ghost 博客平台。

在 Linux 上安装 Ghost

Ghost 由 Node.js 提供支持。因此,首先在 Linux 系统上安装 Node.js。确保 Node.js 的版本为 0.10 或更高版本。

接下来,登录http://ghost.org(需要注册),下载Ghost的源代码。然后按照以下步骤安装 Ghost。


$ sudo mkdir -p /var/www/ghost
$ sudo unzip ghost-0.3.3.zip -d /var/www/ghost
$ cd /var/www/ghost
$ sudo npm install --production

启动前配置 Ghost

在启动 Ghost 之前,请创建位于 /var/www/ghost/config.js 的配置文件,如下所示。将 YOUR_IP 替换为您的主机的 IP 地址。


$ cd /var/www/ghost
$ sudo cp config.example.js config.js
$ sudo sed -i 's/127.0.0.1/YOUR_IP/g' config.js

在开发模式下测试运行 Ghost

此时,您已准备好启动 Ghost。

请注意,Ghost 可以在两种不同的模式下运行:开发 和生产 模式。为了安全起见,Ghost 在其配置文件(/var/www/ghost/config.js)中分别维护了两种模式的配置信息。例如,两种不同的模式使用不同的数据库文件(即位于 /var/www/ghost/content/data 中的 ghost-dev.db 和 ghost.db)。

使用以下命令启动 Ghost。 Ghost 默认以开发模式运行。


$ cd /var/www/ghost
$ sudo npm start

如果 Ghost 成功启动,您应该在终端中看到以下输出,表明 Ghost 正在 :2368 上运行。

在网络浏览器上访问 http://:2368,并验证您是否可以看到以下初始 Ghost 页面。

在生产模式下启动 Ghost

确认 Ghost 运行正常后,按 Ctrl+C 在开发模式下停止 Ghost。现在是时候在生产模式下启动 Ghost 了。

当您在生产模式下运行 Ghost 时,您可以使用名为 forever 的 Node.js 模块,它允许您守护 Ghost,并将其作为后台进程运行。

要安装forever模块:


$ sudo npm install forever -g

最后,在生产模式下启动 Ghost,如下所示:


$ cd /var/www/ghost
$ sudo NODE_ENV=production forever start index.js

验证 Ghost 的数据库是否已在生产模式下成功创建 (/var/www/ghost/content/data/ghost.db)。

您还可以检查永远活动进程的列表。


$ sudo forever list

info:    Forever processes running
data:        uid  command         script   forever pid   logfile                     uptime       
data:    [0] cH0O /usr/bin/nodejs index.js 15355   15357 /home/dev/.forever/cH0O.log 0:0:0:37.741 

如果看到类似上面的输出,则说明 Ghost 已成功在后台运行。

要停止 Ghost 守护程序,请运行以下命令。


$ cd /var/www/ghost
$ sudo forever stop index.js
©2015-2025 艾丽卡 support@alaica.com