Running Ghost On Ubuntu 22.04

@mjw Is Ubuntu 22.04 supported for production now? From the installation guide, 22.04 is supported.

When I tried to install node.js, it simply doesn’t work:

# Add the NodeSource APT repository for Node 16
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash

# Install Node.js
sudo apt-get install -y nodejs

I can only install node 18 when I run the commands. But v16 is not supported. When I try to use nvm to install v16, the folder and permission are not correct again. The npm is installed in my user folder and the directory is not readable by other users. Look like it’s not working.

I can’t find a way to install node.js v16 (which can be used by Ghost) in Ubuntu 22.04.

Yes, this is what I’m running. It was a clean install; I migrated my sites from Linode to Hetzner after rehearsing in a VM.

Note that the user is in the group sudo, i.e., adduser <USER> sudo.

user@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
user@ubuntu:~$ node --version
v16.18.1

Here’s the steps I recorded…

sudo apt update && sudo apt upgrade --yes
sudo apt install mysql-server --yes
sudo systemctl start mysql.service
sudo mysql

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<PASSWORD>';
QUIT;

sudo mysql_secure_installation

sudo mysql -u root -p

CREATE USER '<USER>'@'localhost' IDENTIFIED BY '<PASSWORD>';
CREATE DATABASE <DATABASE>;
GRANT ALL PRIVILEGES ON <DATABASE>.* TO '<USER>'@'localhost';
FLUSH PRIVILEGES;
QUIT;

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash
sudo apt install nodejs --yes
sudo npm install ghost-cli@latest -g
sudo mkdir -p /var/www/<GHOST>
sudo chown <USER>:<USER> /var/www/<GHOST>
sudo chmod 775 /var/www/<GHOST>
cd /var/www/<GHOST>
ghost install

I migrate from Digital Ocean Ubuntu 16.04 to Ubuntu 22.04. Can I know when node 18 lts is supported soon? If v18 is going to be supported soon, I’ll just wait for it. It saves the hassle of upgrading node

I tried to run sudo apt install nodejs=16 in the new Ubuntu machine. I didn’t run apt-get update before.
this is what I get: E: Version '16' for 'nodejs' was not found

Then I tried to run sudo apt install nodejs
node -v
It gives v18.7.0

Look like node v16 is removed

I wouldn’t know since I am a community member, too.

Nonetheless, you first need to setup Apt to install Node 16.

Since you have done a distribution upgrade, and Node was already installed, the latest version for the LTS was installed during the upgrade.

You could try completely removing Node and starting again.

Finally, do make use of DO snapshots; they’re there to help during updates and upgrades. For a few cents you can clone and test the steps, and rollback when things go awry.

I was trying to migrate manually from a ubuntu machine to another one. So it’s not done with do-release-upgrade. I created a new ubuntu 22.04 machine on DO and set it up.

I was installing node with apt-get so it didn’t come with the new ubuntu machine. After installing node v18, I try to remove the installed node with apt remove and reinstall again. But it’s still the same.

You’ll probably need to do a purge to remove any traces, so it may be quicker to rollback to another snapshot, and start installing Ghost again.

However, don’t install Node using Apt until after running curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash.

Incidentally, I’ve moved this discussion to a new thread since the concerned Docker.

You can use the n command to easily manage your Node versions on Debian/Ubuntu.

Details here: GitHub - tj/n: Node version management

TL;DR

sudo npm install -g n

sudo n 16
  installing : node-v16.19.0
       mkdir : /usr/local/n/versions/node/16.19.0
       fetch : https://nodejs.org/dist/v16.19.0/node-v16.19.0-linux-x64.tar.xz
     copying : node/16.19.0
   installed : v16.19.0 (with npm 8.19.3)

node --version
v16.19.0

The Ubuntu and Debian node versions in apt are slow, and some node apps need more precision. I’ve used n to manage a number of hosts for several years.

One gotcha - make sure to remove the Debian/Ubuntu node package, as you may end up confused by multiple versions.

node --version
which node
nodejs --version
sudo apt purge nodejs
# etc