Installing Strapi CMS on Debian 12, utilizing PostgreSQL, PM2, Nginx, and SSL
Setting Up Strapi CMS on Debian 12 with PostgreSQL, PM2, Nginx, and SSL
Debian 12, with its stability, security updates until 2028, and strong compatibility with production-grade software stacks, makes an ideal choice for hosting Strapi CMS. In this article, we'll guide you through the step-by-step process of setting up Strapi on Debian 12, using PostgreSQL as the backend database, PM2 for process management, Nginx as a reverse proxy, and SSL for secure communication.
1. Prepare Debian 12 Server
To start, update your system packages and install essential packages:
2. Install Node.js 20 and npm
Strapi requires Node.js 20 or higher. Install the necessary packages:
3. Install and Configure PostgreSQL
Install PostgreSQL and create a database and user:
4. Create and Set Up Strapi Project
Create a new Strapi project and install the PostgreSQL driver:
Edit (or environment variables) to connect Strapi to PostgreSQL:
Build the project for production:
5. Install and Configure PM2 to Manage Strapi Process
Install PM2 globally:
Create a PM2 config file in the project root with:
Start Strapi with PM2:
6. Install and Configure Nginx as Reverse Proxy
Install nginx:
Create a new Nginx site config :
```nginx server { listen 80; server_name your_domain.com;
} ```
Enable the config and reload Nginx:
7. Secure Nginx with Let’s Encrypt SSL
Install Certbot and its Nginx plugin:
Obtain and install SSL certificate (replace and email accordingly):
Summary of Key Configuration Locations
| Component | Key File / Command | |------------------|--------------------------------------------------------------| | PostgreSQL DB | Created via commands, user and DB configured | | Strapi Project | Strapi installed via , pg module installed | | Strapi DB Config | or environment variables defined | | PM2 Config | with all env vars and start command | | Nginx Config | with reverse proxy setup | | SSL with Certbot | Via command to auto-configure SSL |
This setup leads to a production-ready Strapi CMS running on Debian 12, with PostgreSQL as the backend database, PM2 for process management (auto-restarting and starting on boot), Nginx as a reverse proxy to handle HTTP(S) connections, and SSL for secure communication.
- During step 4, as part of creating the Strapi project, you'll need to ensure that you install the PostgreSQL driver to establish a connection between Strapi and the PostgreSQL database.
- In step 7, once you have installed Let’s Encrypt SSL for secure communication on your Nginx server, you'll also be using technology like Certbot to automate the process of obtaining and installing the SSL certificate.