Installing ghost blog on Webdock "perfect" LEMP server
This was super easy, but one thing I messed up the last time round was the location of the install of the ghost home directory, so redoing and making notes for next time.
Webdock
I was recommended Webdock by a chatbot when following up recommendations for FSIT, a VPS hosting company based in Switzerland. I was looking for something reasonable and Europe based (and IPv4 after struggling along with IPv6). Webdock certainly had great servers for the price compared to the likes of Vultr and Digital Ocean:
- Vultr - $6 /mo - 1GB RAM / 32GB SSD / 1TB transfer
- Digital Ocean - $6/mo - 1GB RAM / 25GB SSD / 1TB transfer
- Webdock - €5 / mo - 2.5GB RAM / 25GB SSD / Free limit
I was initially put off by the extra configuration they did to their servers, but then I found meticulous documentation detailing every step taken and bookmarked it for my own purposes at least, before deciding to give them a go.
Provision a Webdock LEMP server
Because of the extra configuration steps taken, provisioning is even more straight forwards than normal AND they only start charging you for servers from midnight.
- Click the big red "plus" button top right, enter a name for the server (will form part of the server subdomain by default), select SSD Bit "Starter Box" size in Europe and then "The Perfect Server" image
- Click the big green "Create Server" button, again top right
- Takes a couple of minutes to provision at which point you'll have a server running with LEMP installed and configured, as well as shell and mysql users
- Create a shell user and associate public SSH keys for that user to SSH in (add the public SSH keys first if nec). Note password login via SSH is already disabled, just one of many things less to have to configure.
- SSH in using the user and server name previously chosen
Update packages
sudo apt update && sudo apt upgrade
Two php.ini files had changes, so I inspected these and chose the package maintainers version and then updated the files as per the "perfect server" instructions in line with previous changes made (click on "image" name on server overview to go to configurations made)
php.ini: A new version (/usr/lib/php/8.0/php.ini-production.cli) of configuration file /etc/php/8.0/cli/php.ini is available, but the version installed currently has been locally modified.
Show the differences between the versions
memory_limit set back to -1
error_reporting set back to E_All & ~E_DEPRECATED & ~E_STRICT
display_errors set back to Off
;extension=oci8_19 ; Use with Oracle Database 19 Instant Client new comment
date.timezone set back to blank and commented out
correction in comment - mbsting > mbstring
correct in 2 commented out lines mbstring.http_output_conv_mimetype > mimetypes
Install the package maintainers version
php.ini: A new version (/usr/lib/php/8.0/php.ini-production) of configuration file /etc/php/8.0/fpm/php.ini is available, but the version installed currently has been locally modified.
Show the differences between the versions
memory_limit set back to 128M
error_reporting set back to E_All & ~E_DEPRECATED & ~E_STRICT
post_max_size set back to 8M
upload_max_file_size set back to 2M
;extension=oci8_19 ; Use with Oracle Database 19 Instant Client new comment
date.timezone set back to blank and commented out
correction in comment - mbsting > mbstring
correct in 2 commented out lines mbstring.http_output_conv_mimetype > mimetypes
Install the package maintainers version
sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/8.0/cli/php.ini
sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/8.0/cli/php.ini
sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/8.0/cli/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/8.0/cli/php.ini
sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL \& ~E_NOTICE \& ~E_STRICT \& ~E_DEPRECATED/" /etc/php/8.0/fpm/php.ini
sudo sed -i "s/display_errors = .*/display_errors = Off/" /etc/php/8.0/fpm/php.ini
sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/8.0/fpm/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/8.0/fpm/php.ini
sudo sed -i "s/post_max_size = .*/post_max_size = 256M/" /etc/php/8.0/fpm/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/8.0/fpm/php.ini
Install ghost
Add DNS for blog URL
If this hasn't been set up and propagated, SSL configuration will fail, but can be reset up after install if nec using ghost setup ssl
Create user for ghost install
- Create a user (not really sure why):
sudo adduser ghostuser
- Add user to sudoers:
sudo usermod -aG sudo ghostuser
- Log in as the new user:
su - ghostuser
Check node version
The version of node installed was v17.3.0, but ghost requires v16 maximum so if necessary install nvm and a supported version of node and switch to it (this will install nvm as the ghost user)
- Check latest version of nvm from https://github.com/nvm-sh/nvm and run script to install e.g.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install 16.13.1
- message to say switched to this version (actually seemed to have downgraded / removed the v17 install)
Install ghost
- Install ghost cli:
sudo npm install ghost-cli@latest -g
- Create a new directory for ghost:
sudo mkdir -p /var/www/notes.dot.kitchen
- Set directory owner:
sudo chown ghostuser:ghostuser /var/www/notes.dot.kitchen
- Update permissions:
sudo chmod 775 /var/www/notes.dot.kitchen
- Navigate:
cd /var/www/notes.dot.kitchen
- Install:
ghost install
- Ignore mysql error (mariadb is installed which is not detected, pretend you have a remote mysql)
- Enter blog URL: https://notes.dot.kitchen
- Use mysql "user" user given on webdock server details page as well as existing database (same name)
- Y to setting up nginx, ssl, systemd
- Any issues, can rerun individual set up stage e.g.
ghost setup ssl
or whole set upghost setup
(skips already configured and working parts) - Browse to /ghost/ to finish setup
Migrate existing content
- Old site: Settings > Labs > Export
- New site: Settings > Labs > Import
- Warnings x 2 - existing user, theme not imported - OK
- New site: Settings > Staff > Ghost > Delete user
- New site: update post.hbs re hero image (see: https://hooshmand.net/ghost-blog-different-hero-image-feature-image/)
- Old server: cd to content directory and
zip -r ~/images.zip images
- Local:
scp user@old.vps.webdock.io:~/images.zip .
- Local:
scp images.zip user@new.vps.webdock.io:~/.
- New server:
sudo unzip images.zip -d /var/www/notes.dot.kitchen/content/
- New server:
su - ghostuser
- New server:
sudo chown -R ghost:ghost ./content
- New server:
ghost doctor