How to Install Strapi Headless CMS
Strapi is the leading open-source headless CMS built on Node.js. Unlike traditional CMSes that couple content management with presentation, Strapi provides a powerful API (REST and GraphQL) that lets you deliver content to any frontend: websites, mobile apps, IoT devices, or any other platform. This guide covers deploying Strapi on your Breeze instance.
What Is a Headless CMS?
- Decoupled architecture — content management is separated from content delivery
- API-first — content is accessed via REST or GraphQL APIs
- Frontend agnostic — use React, Vue, Angular, mobile apps, or any technology
- Omnichannel — deliver content to multiple platforms from a single source
Prerequisites
- A Breeze instance with Ubuntu 22.04 and at least 2 GB RAM
- Node.js 18+ and npm installed
- MySQL 8.0, MariaDB, or PostgreSQL (SQLite works for development)
- Nginx for reverse proxy
Step 1 — Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
node --version
Step 2 — Create a Strapi Project
npx create-strapi-app@latest my-strapi-project
The installer will ask you to choose between Quickstart (SQLite) or Custom (MySQL/PostgreSQL). For production, select Custom and configure MySQL:
Database client: mysql
Database name: strapi_db
Host: 127.0.0.1
Port: 3306
Username: strapi_user
Password: your_secure_password
Create the database first:
sudo mysql -u root -p -e "CREATE DATABASE strapi_db; CREATE USER 'strapi_user'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL PRIVILEGES ON strapi_db.* TO 'strapi_user'@'localhost'; FLUSH PRIVILEGES;"
Step 3 — Build for Production
cd my-strapi-project
NODE_ENV=production npm run build
Step 4 — Run with PM2
Install PM2 globally and configure Strapi to run as a managed process:
sudo npm install -g pm2
cd /home/user/my-strapi-project
pm2 start npm --name "strapi" -- run start
pm2 save
pm2 startup
Strapi runs on port 1337 by default.
Step 5 — Configure Nginx Reverse Proxy
sudo nano /etc/nginx/sites-available/strapi
server {
listen 80;
server_name api.yourdomain.com;
client_max_body_size 50M;
location / {
proxy_pass http://127.0.0.1:1337;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
sudo ln -s /etc/nginx/sites-available/strapi /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Step 6 — Create Your First Content Type
Access the Strapi admin panel at http://api.yourdomain.com/admin. Create your admin account, then use the Content-Type Builder to define your data models. For example, create a "Blog Post" content type with fields for title (text), body (rich text), featured image (media), and published date (date).
Consuming the API
Once content types are created and entries are added, access them via the REST API:
curl http://api.yourdomain.com/api/blog-posts
Or enable the GraphQL plugin for more flexible queries:
npm run strapi install graphql