Install ghost on a Production VPS
Prerequisites:
- Ubuntu 16.04, Ubuntu 18.04 or Ubuntu 20.04 or Ubuntu 22.04
- NGINX
- node version 14 and up
- MySQL 5.7 or 8.0
- Systemd
- A server with at least 1GB memory
- Domain Name
Step 1. Install nginx
If you are working on an existing server that uses apache2 see this note: replace-apache-with-nginx. See below steps for a new VPS server.
- Optional: Add nginx ppa repository
sudo add-apt-repository ppa:nginx/stable
- Update server, install nginx and allow nginx through firewall
sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade
sudo apt install nginx
sudo ufw allow "Nginx Full"
Step 2. Install and configure MySql
sudo apt install mysql-server
- Create mysql password for user root
sudo mysql_secure_installation
Follow the onscreen prompts.
Step 3. Install node.js
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash
sudo apt install -y node.js
Step 4. Install ghost-cli
sudo npm install ghost-cli@latest -g
Step 5. Create a user to manage the ghost install.
useradd -m -G sudo,www-data casper
passwd casper
Step 6. Login as the newly created user
su casper
Step 7. Install ghost
sudo mkdir -p /var/www/sitename
sudo chown -R casper:casper /var/www/sitename
sudo chmod 744 /var/www/sitename
cd /var/www/sitename
ghost install
The installation will ask a few questions to set up your ghost install.
- Blog URL
- Domain name of your blog. e.g. https://example.com
*Note use https so that ghost will offer to set up ssl for you*
- MySQL hostname
- Defaults to localhost (local install of mysql) you can also use a remote mysql server for this.
- Note that in Ubuntu 22.04 which somehow doesn't allow socket connections to mysql, you can use localhost loopback IP instead (127.0.0.1)
- MySQL username/password
- Use root and the root password
- Ghost database name
- Choose a unique name for the mysql database of your ghost install.
- Set up a ghost MySQL user?
- Answer yes for this so that ghost will use this MySQL user instead of root.
- Set up NGINX?
- Answer yes for this so that you won't have to.
- Set up SSL?
- Answer yes for this as well.
- Enter your email
- This will be used for setting up ssl with letsencrypt.
- Set up systemd?
- Yes so that ghost will be guaranteed to run smoothly.
- Start Ghost?
- Of course yes why else did we set it up.
Notice how mostly everything is automated? It's in line with Ghost's vision to focus on what bloggers should do.... Write
Next step is to fire up the browser and point it to your URL i.e. https://example.com/ghost. This will help you create an admin user for your site. This URL is also your admin panel. From here you can customize your site's theme, add a logo, and do most of the management stuff. For now your site will contain posts on how to write your first post and all have one post that says coming soon.
After that you explore and start writing. Down the line you will be creating your own theme.
Good luck and enjoy.