How to Deploy Strapi App with SEO Plugin on Ubuntu 22.04

How to Deploy Strapi App with SEO Plugin on Ubuntu 22.04

Looking to deploy a Strapi app with an SEO plugin on Ubuntu 22.04? 

Then this guide is for you.

Strapi is an open-source headless Content Management System (CMS) based on Node.js. With Strapi, you can easily create and manage content for various applications, including mobile apps, editorial websites, e-commerce platforms, static sites, corporate portals, and more. 

This tutorial will cover the whole step-by-step process of creating a Strapi project and deploying it with an SEO plugin on an Ubuntu system. 

Let’s get started!

What You’ll Need

Before we dive into the tutorial, it’s vital to ensure that you have all the necessary components in place to set up Strapi. Here’s what you’ll need:

  • An Ubuntu system (version 22.04 or later)
  • Node.js version 18
  • A NodeJS package manager
  • Python for SQLite
  • A database system (MySQL, MariaDB, PostgreSQL, SQLite, etc.)

How to Deploy Strapi App with SEO Plugin on Ubuntu 22.04: Step-By-Step

Now that you know the requirements for installing and deploying Strapi, let’s jump into the steps.

Step 1: Install and Set Up PostgreSQL

For this tutorial, we’ll be using PostgreSQL due to its extensibility. However, you’re not limited to just using PostgreSQL and you’re free to choose another database if you wish to do so.

  1. First, update your system with this command:
$ sudo apt update
  1. After the update, install these necessary packages for interacting with the web and maintaining privacy with this command:
$ sudo apt install curl wget gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates
install necessary packages to setup strapi
  1. Since we will be using PostgreSQL, we will proceed to install the latest PostgreSQL version 14. You should check the installed and available versions of it. Do that with this command:
$ apt policy postgresql
check postgresql version
  1. Next, we need to import the GPG key. This key ensures that the software we install comes from a trusted source. To import the GPG key, enter the following command:
$ curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
add PostgreSQL gpg key
  1. After that, add the PostgreSQL repository using the below command:
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
add PostgreSQL repository to local software package list
  1. Now you must update your package list again to use the newly added PostgreSQL repository Update it with this command:
$ sudo apt update
  1. And then, install PostgreSQL using this command:
$ sudo apt install postgresql-14
install PostgreSQL on ubuntu 22.04
  1. Once you’ve installed PostgreSQL, you can proceed to create a database instance for Strapi so that you can start storing your app data in it. You can do that with these commands (take note to replace the database name with your own):
$ sudo -i -u postgres psql
=# CREATE DATABASE distroid_strapi;

You should also create a user profile for the database. You will use this profile to handle all the database activities for your app. Create the user with the following command (take note  to replace the user name and password with your own):

=# CREATE USER zunaid WITH PASSWORD '12345';

NOTE: It’s crucial to use your own username, database name, and password throughout the above steps. 

  1. Next, let’s make the user the database owner so that we can access and modify the database with that user profile. Without changing ownership, we won’t be able to have the right permissions. To change the ownership, use his command:
=# ALTER DATABASE distroid_strapi OWNER TO zunaid;
create user and database in Postgres
  1. Now exit from Postgres and verify if the user can use the database since this is the user profile you’ll be using to handle the database tasks. To check that, use this command:
$ psql --username zunaid --password --host localhost distroid_strapi
verfify if user can access database

Step 2: Install Node.js

  1. We will need Node.js version 18 for Strapi because this is the version they recommend. First, add the Node.js repo for that version using this command:
$ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
  1. Next, install Node.js with this command:
$ sudo apt-get install nodejs
install nodejs version 18 on ubuntu 22.04
  1. You can check the version of Node.js and NPM to see if you installed the correct versions. Check the versions with these commands:
$ node -v
$ npm -v
check version of nodejs and npm

Step 3: Install Strapi

  1. You can use either Yarn or NPM dependency manager to install Strapi. For the purposes of this guide, we’ll use NPM. You can install Strapi using NPM by running this command:
$ npx create-strapi-app@latest my-project
How to Deploy Strapi App with SEO Plugin on Ubuntu 22.04
  1. Proceed by pressing the ‘y’ key. Answer the questions appropriately. Note that we are doing a custom installation. For the Quickstart installation, the installer will choose SQLite, the database by default. So if you’re following this guide, select Postgres as the database client instead.
  1. Now the installation process will start. When done, you will see an output about the available commands and what to do next. Navigate into the project directory with this command:
$ cd my-project
  1. To build the Strapi application admin panel to control the app, execute the below command:
$ NODE_ENV=production npm run build
create strapi admin panel
  1. After the admin panel is created, start the Strapi project with this command:
$ node ~/my-project/node_modules/.bin/strapi start
start strapi app

This should also open the Strapi admin panel on your browser since we’re running it on localhost. If you see a similar interface as shown in the screenshot below, it indicates that your Strapi application has been successfully installed.

register an admin account on strapi

Step 4: Access and Set Up Strapi App

  1. Now that we’ve successfully installed Strapi, it’s time to set it up. Start by creating an administrator account for the app by filling in the details, as shown in the screenshot below. Enter your name, email, and create a password. Remember to read the terms and tick the box next to it. Once done, press the Let’s start button.
register an admin account on strapi
  1. In the next window, select from the dropdown menu what you’d like to do with the Strapi app. You can even skip this question by clicking the Skip this question button.
register an admin account on strapi
  1. Next, click Finish to complete the onboarding. You will be welcomed to the admin dashboard that looks like this (as shown in the screenshot below):
strapi admin panel

Excellent! We’ve successfully got into our Strapi app. We can now start doing all sorts of tweaks from here. One such tweak will be to install our SEO plugin, which is our main goal with this tutorial. So let’s do that.

Step 5: Install the SEO Plugin

  1. First, go to the Marketplace tab on the left panel.
strapi seo plugin install
  1. In the search bar on the right, type in ‘SEO’ and search. This will automatically bring all the SEO-related plugins. However, we are only interested in the official SEO plugin with the purple-ish logo (as shown in the screenshot below). Press on the More button.
strapi seo plugin install
  1. On the plugin page, you can read everything about the plugin. 
strapi seo plugin install
  1. Before installing the plugin, navigate into the project directory you created earlier while creating the app. Use this command:
$ cd ~/my-project
  1. Next, install the SEO plugin using this command:
$ npm install @strapi/plugin-seo
strapi seo plugin install
  1. To activate the plugin, you’ll need to create a configuration file. For this purpose, we’ll use the Nano text editor. Run the command below to create the file using Nano:
$ nano config/plugins.js

Write the below configuration:

module.exports = ({ env }) => ({

// ...

  seo: {

    enabled: true,

  },

  // ...

});
strapi seo plugin configuration
  1. Press Ctrl + O keys to open the save prompt.
  2. After saving the file, press Ctrl + X keys to exit Nano.
  3. Once you have saved the configuration file, you need to rebuild the admin panel to include the SEO plugin section in the dashboard. Run the following command:
$ NODE_ENV=production npm run build
  1. Now start your Strapi app again—log in using your credentials. You should notice that the SEO plugin was added to your dashboard (as shown in the screenshot below).
seo plugin added to strapi

Step 6: Configuring Strapi Settings

Congratulations! With everything set up, you can go to the Settings tab and start playing around with the different settings, such as API Tokens, Media Library, Webhooks, Admin Panel customization, and user management. 

  1. Once you have your desired settings, save them by pressing the Save button on the top-right corner.
save strapi configuration

In conclusion, this tutorial provided a comprehensive guide on deploying a Strapi app with an SEO plugin on Ubuntu 22.04. We covered the step-by-step process of installing Strapi with custom settings, including the configuration of your own database. 

Furthermore, we explored the installation of the SEO plugin.

We hope that this tutorial has been informative and helpful in your Strapi deployment journey. 

If this guide helped you, please share it.

Related Posts