5

How to Install Strapi on Ubuntu 16.04

 2 years ago
source link: https://www.vultr.com/docs/how-to-install-strapi-on-ubuntu-16-04
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
<?xml encoding="utf-8" ??>

Introduction

Strapi is an open source NodeJS Content Management Framework dedicated to build secure and scalable production-ready API applications and services. In this tutorial, you will learn how to deploy a Strapi project for production on a clean Ubuntu 16.04 server.

Requirements

  • A newly deployed Ubuntu 16.04 server instance
  • A non-root user account with sudo privileges
  • NodeJS version 10.x or greater. NodeJS is a server platform which runs JavaScript
  • NPM version 6.x or greater. NPM is the package manager for Javascript.
  • MongoDB version 3.x or greater. MongoDB is a powerful document store.

Install NodeJS and NPM

Run the following commands to install NodeJS:

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

Check the Node and NPM versions:

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

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

sudo apt-get install build-essential

Install MongoDB

Import the MongoDB GPG key to your system:

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

Once the key is imported, create a list file run:

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

Reload the packages list:

sudo apt-get update

Install MongoDB packages:

sudo apt-get install -y mongodb-org

Start the MongoDB daemon:

sudo service mongod start

Connect to the MongoDB shell:

mongo

Create a MongoDB database with your chosen project name:

use my-api-project

Install Strapi

Run the following commands to install Strapi globally:

npm install strapi@alpha -g

Once the installation has completed, check that the installation went well:

strapi -v
# 3.0.0-alpha.x.

Create a project

Create your first project:

strapi new my-api-project

Answer the following prompts accordingly. In our example, we will choose MongoDB as our main database, enter the database name that was created previously and press ENTER to select the default options. It will look as follows:

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 with the entire file structure of a Strapi application.

Start your server:

strapi start

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

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK