How To Install Strapi on Ubuntu 18.04

Strapi is the most popular open source CMS. Strapi gives developers the freedom to use their favorite tools and frameworks, allowing editors to easily manage their content and distribute it anywhere. This CMS is designed for build secure apps and API services.

Install NodeJS and NPM

To get started you need to install NodeJS and also NPM. To do this, run the following commands:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install nodejs

To check the NodeJS and NPM versions, you can use the following commands:

node -v && npm -v
# v10.x.x
# 6.x.x

In order for some NPM packages to work correctly and well, you need to install the build-essential package:

sudo apt-get install build-essential

Install MongoDB

Import the MongoDB GPG key into your system. To do this, issue the following command:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

After you have successfully imported this GPG key, then you need to create a run list file:

echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

Next, update the list of all packages using the command:

sudo apt-get update

Install all required MongoDB packages:

sudo apt-get install -y mongodb-org

Start MongoDB daemon:

sudo service mongod start

Connect to MongoDB shell:

mongo

Create MongoDB database and select your project name:

use my_api_project_default

Install Strapi

To install Strapi, enter the following command:

npm install strapi@alpha -g

Create Your Personal Project

strapi new  my_api_project_default

Respond appropriately to the following queries. In our example, we will select MongoDB as our main database, enter the database name that was created earlier and press ENTER to select the default options. It will look like this:

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

This will create a new folder named my_api_project_default with the entire file structure of the Strapi application. Then start your server:

strapi start

Now that the Strapi server is running, you can register your first user by going to http://your_server_ip:1337/admin

Was this article helpful?

Related Articles