How to install headless CAC Strapi Node.js

How to install headless CAC Strapi Node.js

Want to develop and use your own custom API? Strapi might be a tool for you. Learn how to quickly play this developer-centered CMS tool.

Strapi is a cross between a content management system (CMS) and the Node.js framework. With this headless tool running in your data center, you will save weeks on API development time. Strapi only offers basic functionality to manage content and users, while allowing you to manage and share that content through REST or GraphQL.

Strapi’s features include:

  • Fully open source
  • Start with development in just a few minutes
  • Built-in GraphQL support
  • Easy API permission management
  • Easily handle relationships between data in Strapi instancesEasy to customize

I will guide you through the fast installation of Strapi headless CMS tools. This method will allow you to create projects and then create content on a project-by-project basis. This will also allow you to quickly test Strapi to see if it’s the right tool for you.

After you make that decision, you can then move to a full-blown installation (which we will discuss later). However, with this method, you will have a Strapi instance that functions 100% that you can use to build your own custom API.

I will show you on Ubuntu Server 18.04, but you can install this system on any platform that supports Node.js and npm.

What do you need

  • Example of running Ubuntu Server 18.04
  • A user with sudo privileges

How to install dependencies

The first thing we have to do is take care of the dependencies. Strapi requires version 10 or newer of Node.js, so the first thing we’ll do is fix it.

Enter your Ubuntu server instance and install the initial dependencies by issuing the command:

sudo apt-get install build-essential apt-transport-https lsb-release ca-certificates curl -y

When finished, download and install Node.js version 12 with the command:

curl -sL | sudo -E bash -

When the Node.js installation is complete, install npm with the command:

sudo apt-get install npm -y

Next, we need to install the thread, which will be used to run the Strapi instance. To do this, first download and add the required apt key with the command:

curl -sS | sudo apt-key add -

Add thread repositories with the command:

echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Finally, attach the thread with the command

sudo apt update && sudo apt install yarn

When it’s finished, you are ready to play the Strapi instance.

How to run instances of Strapi

Back at the command line, you will start the derivative of Strapi (while also creating a new project) with the command:

yarn create strapi-app PROJECT_NAME --quickstart

Where PROJECT_NAME is the name of the project you want to create.

This will take a little time (between two to five minutes). When finished, you will be presented with a screen that displays the address that you can reach the server (Figure A).

Figure A


Example Strapi is running.

The problem is, this will try to open the browser from that command. Because we installed this on a server without a GUI, that won’t happen. So instead of pointing the browser to http: // localhost: 1337 / admin, you will open the browser on another computer (one on your LAN) and point it to http: // SERVER_IP: 1337 (where SERVER_IP is the IP address of the hosting server Strapi). Don’t add the / admin section of the URL, because that will give you an error.

You will see a welcome screen, asking you to create an administrator (Figure B).

Figure B


Welcome to Strapi and create your administrator.

Click Create First Administrator. Fill in the required information and click Ready To Start (Figure C).

Figure C.


Make a Strapi administrator.

You will then be greeted by the Strapi main window, where you can start building your first content (Figure D).

Figure D


Strapi main window.

Congratulations, you have Strapi up and running, where you can build and use content. Just remember, your Strapi instance still runs in the terminal window. If you close the terminal window, your Strapi server will stop running. So when you want to use Strapi to create a new project, you will issue a thread command to create it.

Running Strapi in this way requires that you maintain Strapi and run it until you complete the project. You cannot start a project, close it, and restart the same project. For this reason, Strapi needs to be installed as a stand-alone server, not spun with thread.

Next time, we will install a complete example of Strapi that doesn’t depend on threads and uses MongoDB as its database.

Related posts

How to Make a Minecraft Server on Ubuntu 20.04


How to Use Sudo Commands on Linux


How to run Linux on an Android device


How to use the chmod command on Linux


How to Install KVM on Ubuntu 20.04 LTS


How to Install and Use TeamViewer on Linux


How to Install MariaDB on Ubuntu 20.04


How to Monitor CPU Usage in Linux Over Time


How to install Chef Server and Chef Client on Ubuntu 20.04