Learn how to deploy Strapi on AlmaLinux 10 using Nginx and PM2.
In today’s modern web development landscape, Strapi stands out as a powerful open-source headless CMS. Whether we’re building a personal blog, eCommerce backend, or enterprise-grade content hub, Strapi gives us full control of APIs, content types, and user roles. In this tutorial, we’ll walk through deploying a Strapi instance on an AlmaLinux 10 server, using Nginx as a reverse proxy and PM2 for process management.
What is Strapi?
Strapi is an open-source headless CMS (Content Management System) built on Node.js. It allows developers to create and manage content through APIs without dealing with a traditional monolithic CMS. With Strapi, we can define custom content types, roles, permissions, and REST or GraphQL APIs — all from an easy-to-use admin panel.
Strapi is highly customizable, supports multiple databases (like PostgreSQL, MySQL, SQLite), and is perfect for building scalable, modern applications — whether it’s a blog, e-commerce backend, or mobile app API.
Prerequisites
Before we begin, let’s ensure our environment meets the following requirements:
- A AlmaLinux 10 installed dedicated server or KVM VPS.
- A non-root user with sudo privileges.
- Basic knowledge of using the terminal.
- A domain name pointing to server IP.
Learn how to deploy Strapi on AlmaLinux 10 using Nginx and PM2.
Step 1: Update AlmaLinux 10 and Install Essential Tools
We begin by updating our system and installing basic tools:
sudo dnf update -y
sudo dnf install -y git curl nano gcc-c++ make
These tools ensure compatibility when compiling Node modules or managing files.
Step 2: Install Node.js (LTS Version)
Strapi runs on Node.js. We install the recommended LTS version:
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo dnf install -y nodejs
Verify installation:
node -v
npm -v
Step 3: Install Yarn (Recommended Package Manager)
Yarn helps us manage dependencies more efficiently:
sudo npm install -g yarn
Check the version:
yarn -v
Step 4: Install and Configure PostgreSQL
PostgreSQL is a preferred database for Strapi in production. Install it via DNF:
sudo dnf install -y postgresql-server postgresql-contrib
Initialize and start the database:
sudo postgresql-setup --initdb
sudo systemctl enable postgresql
sudo systemctl start postgresql
Then switch to the postgres user to set up a database and user for Strapi:
sudo -i -u postgres
In the PostgreSQL shell:
psql
CREATE DATABASE strapidb;
CREATE USER strapiuser WITH PASSWORD 'securepassword';
ALTER ROLE strapiuser SET client_encoding TO 'utf8';
ALTER ROLE strapiuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE strapiuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE strapidb TO strapiuser;
\c strapidb
GRANT ALL ON SCHEMA public TO strapiuser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO strapiuser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO strapiuser;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO strapiuser;
\q
exit
Change securepassword to something strong and private.
Change PostgreSQL Authentication Method from ident to md5
Open the PostgreSQL host-based authentication config file:
sudo nano /var/lib/pgsql/data/pg_hba.conf
Look for a line like this:
# TYPE DATABASE USER ADDRESS METHOD
local all all ident
Change it to:
local all all md5
Also ensure this is present for TCP connections:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Save and exit the file, then restart PostgreSQL to apply the changes:
sudo systemctl restart postgresql
Step 5: Create a Strapi Project Using PostgreSQL
Navigate to the folder where you want your project:
npx create-strapi-app@latest my-strapi-app --dbclient=postgres --dbhost=127.0.0.1 --dbname=strapidb --dbport=5432 --dbusername=strapiuser --dbpassword=securepassword
Choose “custom (manual settings)” if prompted, and follow the interactive setup.
🚀 Welcome to Strapi! Ready to bring your project to life?
Create a free account and get:
✨ 30 days of access to the Growth plan, which includes:
✅ Single Sign-On (SSO) login
✅ Content History
✅ Releases
? Please log in or sign up. Skip
? Start with an example structure & data? Yes
? Start with Typescript? Yes
? Install dependencies with npm? Yes
? Initialize a git repository? Yes
This will install dependencies and configure the project automatically.
Step 6: Start and Build Strapi
Once installation is complete, navigate to the project folder:
cd my-strapi-app
Build the admin panel:
yarn build
Step 7: Install and Configure PM2 to Manage Strapi
PM2 keeps the app running and restarts it on reboot or crash:
sudo npm install -g pm2
pm2 start yarn --name strapi -- start
pm2 save
pm2 startup
Copy the systemd command PM2 prints and run it. This ensures Strapi auto-starts on boot.
Step 8: Install and Configure Nginx as a Reverse Proxy
Install Nginx:
sudo dnf install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
Create a new configuration for Strapi:
sudo nano /etc/nginx/conf.d/strapi.conf
Paste this:
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://127.0.0.1:1337;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
Step 9: Secure the Server with Firewall and (Optional) SELinux
If firewalld is running, allow HTTP traffic:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
By default, SELinux blocks Nginx from acting as a proxy. We must allow it explicitly:
sudo setsebool -P httpd_can_network_connect 1
Step 10: Add HTTPS with Let’s Encrypt
To secure your site with HTTPS:
sudo dnf install -y epel-release
sudo dnf install -y certbot python3-certbot-nginx
Run Certbot to automatically configure SSL:
sudo certbot --nginx -d your_domain.com
Step 11: Done! Access Strapi Admin Panel
Once everything is running:
Access the admin panel at http://your_domain.com/admin
- Manage your CMS content securely and reliably
- Use pm2 list to monitor your app
- Logs are available via pm2 logs strapi
Final Thoughts
By deploying Strapi with PostgreSQL on AlmaLinux 10, we’ve set up a powerful backend platform that’s secure, scalable, and easy to manage. PostgreSQL offers superior performance and data integrity, making it an ideal companion for Strapi in production.
With Nginx as the front-facing proxy and PM2 ensuring uptime, this deployment stack is well-suited for powering modern APIs, apps, and websites—without compromise.
Keep your system patched, monitor your logs, and scale as needed. This is the foundation for a professional-grade CMS backend.
Checkout our low cost dedicated servers.