【风笙】VirtualBox安装Ubuntu Desktop 18.04 系统
目录:
Ghost是建立在Node.js平台之上的现代源代码发布平台。 它是完全可定制的并且易于使用,使您可以以几乎零的学习曲线发布内容。
在本教程中,我们将向您展示如何使用Nginx作为代理,免费的Let's Encrypt SSL证书,最新的LTS版本的Node.js和MySQL / MariaDB作为数据库后端,在Ubuntu 18.04服务器上部署安全的Ghost博客。 。
先决条件
作为遵循本教程的前提条件,您将需要:
- 根据官方的Ghost系统要求,您至少需要1G的RAM。 如果服务器的RAM小于1GB,则可以创建交换文件。一个指向您的公共服务器IP的域名。 在本教程中,我们将使用
example.com.Nginx通过遵循如何在Ubuntu 18.04上安装Nginx进行安装;防火墙是通过遵循如何在Ubuntu 18.04上使用UFW设置防火墙进行配置的。 确保端口80和443打开。
在继续本教程之前,请确保您以具有sudo特权的用户身份登录。
安装Node.js和Yarn
在撰写本文时,建议的Ghost Node.js版本是v8 carbon LTS。 我们将从NodeSource存储库安装Node.js。
使用以下curl命令为Node.js v8启用NodeSource存储库:
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
通过键入以下命令安装Node.js:
sudo apt install nodejs
有关其他安装方法,请参阅我们的《如何在Ubuntu 18.04上安装Node.js》指南。
要安装yarn,请使用以下命令在系统上启用Yarn存储库:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
启用存储库后,使用以下命令安装yarn
sudo apt update
sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn
安装MySQL
Ghost支持MySQL,MariaDB和SQLite数据库。 在本教程中,当您在生产模式下运行Ghost时,我们将使用MySQL(推荐的数据库)。
使用以下命令安装MySQL软件包:
sudo apt install mysql-server
运行
mysql_secure_installation
命令以提高MySQL安装的安全性:
sudo mysql_secure_installation
系统将要求您配置
VALIDATE PASSWORD PLUGIN
,该
VALIDATE PASSWORD PLUGIN
用于测试MySQL用户密码的强度。 密码验证策略分为三个级别:低,中和强。 如果您不想设置验证密码插件,请按
ENTER
。
在下一个提示符下,将要求您设置MySQL root用户的密码。
一旦设置了root密码,脚本还将要求您删除匿名用户,限制root用户对本地计算机的访问并删除测试数据库。 您应该对所有问题回答
Y
(是)。
接下来,我们需要将身份验证方法从
auth_socket
更改为
mysql_native_password
,以便Ghost安装程序可以访问我们的MySQL服务器。 为此,请以root用户身份登录到MySQL服务器:
sudo mysql
并运行以下查询,该查询将在使用
mysql_native_password
方法时为MySQL root用户设置密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_pasword';
FLUSH PRIVILEGES;
确保您使用强密码更改
very_strong_pasword
。
安装Ghost-CLI
我们将使用官方的Ghost CLI实用程序安装Ghost。 使用此实用程序,您可以在单个命令中安装或更新Ghost。
Ghost CLI作为npm软件包提供。 以下命令将在您的Ubuntu系统上全局安装Ghost CLI:
sudo yarn global add ghost-cli
创建Ghost安装位置
我们将在建议的安装位置
/var/www/ghost
目录中下载并安装Ghost。
要创建目录类型:
sudo mkdir -p /var/www/ghost
将目录的所有权更改为您的用户:
sudo chown $USER:$USER /var/www/ghost
$USER
是一个环境变量,用于保存您的用户名。
设置正确的目录权限:
安装Ghost
现在,您已经安装了Ghost CLI,并且所有先决条件已经完成,我们可以从安装开始。
转到
/var/www/ghost
目录。
cd /var/www/ghost
要开始安装,请运行
ghost install
,它将安装和配置Ghost,将Nginx配置为反向代理,并通过免费的SSL证书加密来保护站点。
ghost install
✔ Checking system Node.js version ✔ Checking logged in user ✔ Checking current folder permissions System checks failed with message: 'Linux version is not Ubuntu 16' Some features of Ghost-CLI may not work without additional configuration. For local installs we recommend using `ghost install local` instead. ? Continue anyway? (y/N) y
安装程序将检查您的系统并打印一些警告,如上所示。 键入
y
继续,安装程序将下载并安装Ghost:
ℹ 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 v1.24.9 ✔ Finishing install process
接下来,将提示您设置博客URL和MySQL信息。 提供在“
Installing MySQL
部分中设置的根用户名和密码,并使用默认的数据库名称
ghost_prod
。
? Enter your blog URL: https://example.com ? Enter your MySQL hostname: localhost ? Enter your MySQL username: root ? Enter your MySQL password: ? Enter your Ghost database name: ghost_prod
安装程序将创建一个名为
ghost
的系统用户,并询问您是否要创建一个MySQL MySQL用户,请输入
Yes
。
✔ Configuring Ghost ✔ Setting up instance Running sudo command: chown -R ghost:ghost /var/www/ghost/content ✔ Setting up "ghost" system user ? Do you wish to set up "ghost" mysql user? Yes ✔ Setting up "ghost" mysql user
接下来,安装程序将询问您是否要设置Nginx。 输入
Yes
确认。
? Do you wish to set up Nginx? Yes ✔ Creating nginx config file at /var/www/ghost/system/files/example.com.conf Running sudo command: ln -sf /var/www/ghost/system/files/example.com.conf /etc/nginx/sites-available/example.com.conf Running sudo command: ln -sf /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf Running sudo command: nginx -s reload ✔ Setting up Nginx
设置好Nginx之后,安装程序将询问您是否要设置SSL。 输入“
Yes
确认,配置向导将要求您输入电子邮件地址,然后它将为您的域生成一个免费的“让我们加密SSL”证书并配置Nginx。
? Do you wish to set up SSL? Yes ? Enter your email (used for Let's Encrypt notifications) [email protected] Running sudo command: mkdir -p /etc/letsencrypt Running sudo command:./acme.sh --install --home /etc/letsencrypt Running sudo command: /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain example.com --webroot /var/www/ghost/system/nginx-root --reloadcmd "nginx -s reload" --accountemail [email protected] Running sudo command: openssl dhparam -out /etc/nginx/snippets/dhparam.pem 2048 Running sudo command: mv /tmp/ssl-params.conf /etc/nginx/snippets/ssl-params.conf ✔ Creating ssl config file at /var/www/ghost/system/files/example.com-ssl.conf Running sudo command: ln -sf /var/www/ghost/system/files/example.com-ssl.conf /etc/nginx/sites-available/example.com-ssl.conf Running sudo command: ln -sf /etc/nginx/sites-available/example.com-ssl.conf /etc/nginx/sites-enabled/example.com-ssl.conf Running sudo command: nginx -s reload ✔ Setting up SSL
接下来,安装程序将询问您是否要设置systemd服务。 输入
Y
接受,安装程序将创建一个名为ghost_example-com的新systemd服务,并使其在启动时启动:
? Do you wish to set up Systemd? Yes ✔ Creating systemd service file at /var/www/ghost/system/files/ghost_example-com.service Running sudo command: ln -sf /var/www/ghost/system/files/ghost_example-com.service /lib/systemd/system/ghost_example-com.service Running sudo command: systemctl daemon-reload ✔ Setting up Systemd
最后,安装程序将设置数据库,并询问您是否要启动Ghost,输入
Yes
。
Running sudo command: /var/www/ghost/current/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current ✔ Running database migrations ? Do you want to start Ghost? Yes Running sudo command: systemctl is-active ghost_example-com ✔ Ensuring user is not logged in as ghost user ✔ Checking if logged in user is directory owner ✔ Checking current folder permissions Running sudo command: systemctl is-active ghost_example-com ✔ Validating config ✔ Checking folder permissions ✔ Checking file permissions ✔ Checking content folder ownership ✔ Checking memory availability Running sudo command: systemctl start ghost_example-com ✔ Starting Ghost Running sudo command: systemctl is-enabled ghost_example-com Running sudo command: systemctl enable ghost_example-com --quiet ✔ Starting Ghost You can access your publication at https://example.com Next, go to your admin interface at https://example.com/ghost/ to complete the setup of your publication Ghost uses direct mail by default To set up an alternative email method read our docs at
完成Ghost设置
打开浏览器,转到
https://example.com/ghost/
上的Ghost管理界面,将显示以下屏幕:




在这里,您可以创建新帖子,添加用户并更改Ghosts配置。
结论
在本教程中,您学习了如何安装可用于生产的Ghost实例。
现在,您应该访问Ghost帮助页面,并了解有关如何管理Ghost安装的更多信息。 您还可以访问Ghost市场并发现Ghost主题。
ghost nodejs npm ubuntu博客如何在Ubuntu Linux中安装最新的Firefox 3.6.6
Firefox 3.6.6具有浏览器防崩功能。下面介绍如何在Ubuntu Linux中轻松安装它。
如何在Ubuntu 18.04上添加交换空间
交换是物理RAM内存已满时使用的磁盘空间。 当Linux系统的RAM用完时,非活动页面将从RAM移动到交换空间。 本教程介绍了将交换文件添加到Ubuntu 18.04所需的步骤。
如何在Ubuntu Linux中更改root密码
本教程说明了如何临时更改root用户帐户,以及如何在Ubuntu系统上设置root密码。 root用户(或超级用户)是在所有类似Linux和Unix的系统上都存在的特殊用户帐户。







