How to Install Strapi API on Ubuntu 18.04
4 min read

How to Install Strapi API on Ubuntu 18.04

In this tutorial, you will install Strapi on Ubuntu 18.04. Strapi is an open-source framework for content management which aids in the development of database-driven websites, applications, and APIs.
How to Install Strapi API on Ubuntu 18.04


Before we begin talking about how to install Strapi API CMS on Ubuntu 18.04, let’s briefly understand - What is Strapi?

Strapi is an open-source framework for content management which aids in the development of database-driven websites, applications, and APIs. It operates on Node.js and MongoDB.

There are a number of aspects through which Strapi eases our tasks. These are Content management, authentication and permissions management, API generator, etc.

In this tutorial, you will install Strapi on Ubuntu 18.04. We will also address a few FAQs related to the Strapi.

The following packages will be set in the course of this tutorial:

  • Ruby version 2.5.3
  • MongoDB
  • Node.js 10

Step 1 -  Installing Ruby

In order to install Ruby and Rails on Ubuntu, you need to have certain dependencies. For this, you have to install Node.js and yarn, which will make the installation of the dependencies easier.

1) Firstly, you'll have to install the following curl and git packages.

sudo apt update
sudo apt install curl git

2) Run the commands given below to add the Node.js and Yarn repositories along with keys to your system. After this, install some core packages to set up the environment.

curl -sL | sudo -E bash -
curl -sS | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update
sudo apt-get install nodejs yarn zlib1g-dev build-essential libpq-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev

3) After that, install Ruby with your local profile settings using rbenv, which will be used to install ruby-build.

cd ~/
git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

4) Once the settings are saved, install the latest version of Ruby. Replace the number 2.5.3 with the latest version. You can find the latest version of Ruby here.

rbenv install 2.5.3
rbenv global 2.5.3

5) You can verify the installation with the help of the following command.

ruby -v

Below output should appear:

ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]

Step 2 - Installing Node.js

1) The following commands need to be run to install the Node.js. Post installing Node.js repositories, install Node.js package.

curl -sL | sudo -E bash -

sudo apt-get install -y nodejs

Step 3 - Installing MongoDB

1) Strapi uses the MongoDB database. Therefore, MongoDB and ImageMagic needs to be installed before continuing.

sudo apt install mongodb
npm install mongodb --save

2) Once you have installed MongoDB server, open a new terminal window.

3) Now start an interactive Mongo prompt with the help of the following command


Use Ctrl+C to exit

Step 4 - Installing Strapi

1) Once the environment is ready, you can start installing Strapi and build your first website with the help of the following commands:

sudo npm install [email protected] -g

sudo npm install pm2 -g

2) Now, create a new folder, then change it to the strapi folder and install it there.

cd ~
strapi new myproject
cd myproject
npm install --production

3) Answer Y to answer the configuration question, opting for all the default options.

Lets configurate the connection to your database:
? Choose your main database: MongoDB
? Database name: myproject
? Host:
? +srv connection: false
? Port (It will be ignored if you enable +srv): 27017
? Username: leave blank
? Password: leave blank
? Authentication database (Maybe "admin" or blank): 
? Enable SSL connection: false

4) After all the questions have been answered, the generator will prepare the skeleton for your app. Install and configure npm dependencies as required.

5) Once you're done, run the following command to start the server from the Strapi folder.

NODE_ENV=production pm2 start server.js --name api

Alternatively, you can use:

strapi start

6) In case the above commands don't work, open your browser, browse to the hostname followed by #1337.


http://localhost:1337 should enable you to access your Strapi Api.

7) You can stop the server by using Ctrl+C .

8) Now, login to the back-end to begin creating content.

Strapi Welcome Screen

9) Use the credentials for admin.

Strapi Admin Login

10) You can now kick start creating content.

Strapi Admin Dashboard

You now have successfully installed Strapi on Ubuntu 18.04

FAQs to Install Strapi API CMS on Ubuntu 18.04

1) What version of Node.js and npm is required for Strapi?

You have to use the latest LTS version of Node.js and npm.

2) Can we use Strapi in Production?

Yes, many companies already use Strapi stack in production.


We hope this detailed guide helped you understand how to install Strapi on Ubuntu 18.04 server. To learn more about Strapi installation on Ubuntu 18.04 server, check out the official Strapi installation document.

If you have any queries, please leave a comment below and we’ll be happy to respond to them for sure.