Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Installing Strapi and Deploying with Nginx Locally

Tech 2

Strapi is an open-source headless content management system built with JavaScript and powered by Node.js. It provides an intuitive admin panel for managing content through APIs.

Creating a New Project with Strapi

To initiate a new project, execute the following command:

npx create-strapi-app@latest my-project

You will be prompted to choose between "quickstart" and "custom" installation options.

The quickstart option configures Strapi to use its default SQLite database, which is recommended for initial setup. Proceeding with quickstart is straightforward and avoids complications during the setup process.

In contrast, using a local MySQL data base may introduce issues when transferring data between projects. Therefore, it's advisable to opt to the default database unless specific requirements demand otherwise.

Starting the Application

Launch the application using the development mode:

npm run develop

Once running, access the admin panel at http://localhost:1337/admin/.

Local Deployment Using Nginx

For managing Node.js services, consider installing PM2:

npm install pm2 -g

Basic PM2 commands include:

  • pm2 start <app> – Start an application
  • pm2 stop <ID> – Stop a specific service
  • pm2 stop all – Stop all services

Create a server.js file in the project root directory to manage Strapi:

const strapi = require('@strapi/strapi');
const application = strapi({ distDir: './dist' });
application.start();

Next, configure Nginx by modifying nginx.conf:

server {
    listen       80;
    server_name  localhost;

    location / {
        proxy_pass http://localhost:1337;
    }
}

After saving the configuration, restart Nginx to apply changes.

Installing Strapi v5

Ensure Node.js version 18 or higheer is installed before proceeding.

Use the following command to create a new Strapi v5 project:

npx create-strapi my-strapi-project

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.