📜 ⬆️ ⬇️

Recipe for installing a GHost blog in VMManager for Debian 9

Objective: To write a recipe for VMManager, with the recipe itself at the end. As a result, simplify the installation of the blog GHost for untrained users.

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

The reason for writing this article lies in the fact that only for the last month I have been asked for help for the second time in the installation of GHost, and they are overwhelmed with banal. I looked for installation instructions and realized that an ordinary user who does not communicate with the console probably would not quickly test them.

Go…
')
First you need to understand how a recipe is written in general, 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 clean bash, that is, you need to write a script that installs 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 obtained from the official Debian repositories, at the time of this writing there are 6.11.4 ~ dfsg-1 version.
Those to whom this idea may seem risky can use the NodeJS repositories from the official site.

Nginx and yarn will be installed from the pre-repositories. To add unstable repository you need this line.

If you do not need a recipe for the panel, but simply need to put GHost through the console on Debian 9, then you can execute all the commands in the console from the root user. This recipe has been 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 during the update process will migrate from a stable to an unstable branch, and since we don’t 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 placed only if we directly specify the unstable repository as desired in the installation team.

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 adhere to 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 see here and here

Run the installation of GHost

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

 hostname -f 

print your domain name to the console, otherwise replace this line and further 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 correct 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) 

Remove the default configuration file in nginx

 rm /etc/nginx/sites-enabled/default 

Configuring 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 

Source: https://habr.com/ru/post/339360/


All Articles