The recipe for installing a GHost blog in VMManager for Debian 9

  • Tutorial
Purpose: To give a methodology for writing a recipe for VMManager, with the recipe itself at the end. As a result, simplify the installation of the GHost blog for unprepared users.

Target audience: Bloggers and those who want to become them, as well as hosters who want to use a similar recipe and are just administrators.

The reason for writing the article lies in the fact that only for the last month for the second time I have been asked for help in installing GHost, and they are falling into a banal one. I looked for installation instructions and realized that an ordinary user who does not communicate with the console will probably not quickly try them.

Let's go ...

First you need to understand how the recipe is generally written, who are interested in this knowledge I picked up here

After reading the principle of creating a recipe, I got this:

#!/bin/bash
#
# metadata_begin
# recipe: ghost
# tags: debian9
# revision: 1
# description_ru: Тут будет описание когда рецепт будет готов напишем его.
# metadata_end
#

Everything else is pure bash, that is, you need to write a script that puts all the necessary programs for ghost to work. We list these programs:

  1. NodeJS> = 4.5 <5> = 6.9 <7
  2. Nginx
  3. yarn

NodeJS of the required version can be taken from the official Debian repositories, at the time of writing, there is 6.11.4 ~ dfsg-1 version.
Those who may find this idea risky can use NodeJS repositories from the official site.

We will install Nginx and yarn from the predefined repositories. To add an unstable repository, you need such a line.

If you do not need a recipe for the panel, but just need to install GHost through the console on Debian 9, then you can execute all the commands in the console from the root user. This recipe was tested only on Debian 9, although it should work on other versions of Debian too.

echo 'deb http://ftp.ru.debian.org/debian unstable main' > /etc/apt/sources.list.d/nodejs.list

But if you leave this line without editing its priority in the system, the server will flow from a stable branch to an unstable branch during updates, and since we do not need to set priorities.

echo -e 'Package: *\nPin: release a=unstable\nPin-Priority: -9' > /etc/apt/preferences

Now packages from an unstable repository will be installed only if we directly specify an unstable repository as desired in the installation command.

Now you need to update the list of packages.

apt update

Install NodeJS

apt -y install --no-install-recommends -t unstable nodejs npm

Now install Nginx and yarn

apt -y install --no-install-recommends nginx-light yarn

Now we will follow the official installation instructions .

Add user

adduser --shell /bin/bash --gecos 'Ghost application' ghost --disabled-password

Install ghost-cli

npm i -g ghost-cli

Explanation of the launch options can be viewed by running in the console

ghost help

or look here and here

We start the installation of GHost

If you are the one who uses the manual to install GHost, before running this command make sure that the command

hostname -f

displays your domain name in the console, otherwise replace in this line and in the following commands $ (hostname -f) with your domain name


ghost install -d /var/www/$(hostname -f) --no-stack --url http://$(hostname -f) --db sqlite3 --dbpath /home/ghost/bd --no-setup-nginx --no-setup-systemd --no-start

We will fix the rights after installation

chown -R ghost:ghost /var/www/$(hostname -f)

Go to the folder with the site to complete the installation

cd /var/www/$(hostname -f)

Delete the default configuration file in Nginx

rm /etc/nginx/sites-enabled/default

Configure Nginx

ghost setup nginx

configure the daemon and run it

ghost setup systemd && ghost start

Can be used as a script to install GHost

See what happened
#!/bin/bash
#
# metadata_begin
# recipe: ghost
# tags: debian9
# revision: 1
# description_ru: Установка GHost
# metadata_end
#
echo 'deb http://ftp.ru.debian.org/debian unstable main' > /etc/apt/sources.list.d/nodejs.list
echo -e 'Package: *\nPin: release a=unstable\nPin-Priority: -9' > /etc/apt/preferences
apt update
apt -y install --no-install-recommends -t unstable nodejs npm
apt -y install --no-install-recommends nginx-light yarn
adduser --shell /bin/bash --gecos 'Ghost application' ghost --disabled-password
npm i -g ghost-cli
ghost install -d /var/www/$(hostname -f) --no-stack --url http://$(hostname -f) --db sqlite3 --dbpath /home/ghost/bd --no-setup-nginx --no-setup-systemd --no-start
chown -R ghost:ghost /var/www/$(hostname -f)
cd /var/www/$(hostname -f)
rm /etc/nginx/sites-enabled/default
ghost setup nginx
ghost setup systemd && ghost start

Only registered users can participate in the survey. Please come in.

Did this instruction help you?

  • 22.2% Yes, it helped 2
  • 33.3% No, it didn’t help 3
  • 33.3% picked up script 3
  • 0% I am a representative of a hosting company, also added such a recipe to myself 0
  • 0% I am a representative of a hosting company, also added to myself such a recipe with some changes 0
  • 11.1% I am a representative of a hosting company the recipe is useless 1

Also popular now: