Strapi Installation and Production Environment Configuration on Ubuntu 22.04
What Will You Learn in This Guide?
In this guide, you will learn how to install the Strapi CMS application on Ubuntu 22.04 suitable for production environment.
You will use a PostgreSQL database, run it behind an Nginx reverse proxy, ensure it runs continuously with PM2, and secure it with HTTPS.
🧠 Technical Summary
- Subject: Strapi production installation
- Problem: Development mode is insufficient for the production environment
- Solution: PostgreSQL + Nginx + PM2 + Let's Encrypt
- Conclusion: A secure, scalable and stable Strapi CMS
Preliminary Preparations
The following must be ready:
- A server with Ubuntu 22.04 installed
- At least 2 CPU / 4 GB RAM
- Node.js 16.x must be installed
- PostgreSQL must be installed
- Nginx must be configured as a reverse proxy
- A domain name pointed to the server (example:
cms.ornek.com)
1️⃣ Preparing the PostgreSQL Database
Strapi requires a clean database. An existing database should not be used.
sudo -i -u postgres createdb strapi_db
- This command creates a new database for Strapi.
sudo -i -u postgres createuser --interactive
- In this step, a new PostgreSQL user is created.
Enter PostgreSQL shell:
sudo -u postgres psql
- Assign a strong password to the user:
ALTER USER strapi_user PASSWORD 'guclu_bir_sifre';
Sign out:
\q
2️⃣ Strapi Setup
- We will install Strapi with npx.
npx create-strapi-app@latest strapi-project
- This command starts the Strapi installation wizard.
Recommended choices:
1. Installation type: Custom
**2. Language:**JavaScript
3. Database: PostgreSQL
4. Host: 127.0.0.1
5. Port: 5432
6. SSL: No
After the installation is completed, enter the project directory:
cd strapi-project
- Get production build:
NODE_ENV=production npm run build
- This process compiles the Strapi management panel for production.
Start Strapi for testing purposes:
node node_modules/.bin/strapi start
- You can access the administration panel from the browser:
http://alan_adiniz/admin
3️⃣ Running Strapi in the Background with PM2
- PM2 keeps Node.js applications running at all times.
sudo npm install pm2 -g
Create PM2 configuration file:
nano ecosystem.config.js
module.exports = {
apps: [{
name: "strapi",
cwd: "/home/ubuntu/strapi-project",
script: "npm",
args: "start",
env: {
NODE_ENV: "production",
DATABASE_HOST: "localhost",
DATABASE_PORT: "5432",
DATABASE_NAME: "strapi_db",
DATABASE_USERNAME: "strapi_user",
DATABASE_PASSWORD: "guclu_bir_sifre"
}
}]
}
- This file allows Strapi to run in the production environment.
Start:
pm2 start ecosystem.config.js
- Automatic start at server startup:
pm2 startup
pm2 save
4️⃣ HTTPS and Let's Encrypt Configuration
-
The production environment is incomplete without HTTPS.
-
Install Certbot:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
- Update firewall settings:
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
Get the SSL certificate:
sudo certbot --nginx -d cms.ornek.com -d www.cms.ornek.com
- This automatically installs HTTPS and adds the refresh task.
✅ Post-Installation Checks
1. https://yourdomain\_name → Does Strapi open?
2. https://yourdomain\_name/admin → Is the administration panel accessible?
3. pm2 list → Does Strapi appear online?
❓ Frequently Asked Questions (FAQ)
1. Why does Strapi require Node.js 16? Strapi may be incompatible with Node 18+ in some versions.
2. Why did we use PostgreSQL instead of SQLite? For performance and data integrity in the production environment.
3. Is PM2 necessary? Yes. Applications that run on the terminal are not suitable for production.
4. Is SSL renewal automatic? Yes. Certbot adds an auto-refresh scheduler.
🎯 Result
With this guide you can learn Strapi:
Production compatible
safe
scalable
constantly working
You turned it into a structure.
You can immediately publish your Strapi-based projects on the GenixNode infrastructure and use them without any problems with high-performance servers.

