Strapi Installation and Setup
Strapi is installed as a Node.js application. In development mode, hot reload is available and Content-Type Builder is accessible. In production mode, Content-Type Builder is disabled and configuration is code-only.
Requirements
- Node.js 18 or 20 (LTS)
- npm 6+ / yarn 1.22+ / pnpm 6+
- PostgreSQL / MySQL / SQLite
Installation
npx create-strapi-app@latest my-strapi --dbclient=postgres
# Interactive prompt will ask for:
# Database: postgres
# Host: localhost
# Port: 5432
# Name: strapi_db
# Username: strapi
# Password: ...
# SSL: No (for local development)
cd my-strapi
npm run develop
Configuration
// config/database.js
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
connectionString: env('DATABASE_URL'),
ssl: env.bool('DATABASE_SSL', false)
? { rejectUnauthorized: false }
: false,
},
pool: { min: 2, max: 10 },
},
})
// config/server.js
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: env('PUBLIC_URL', 'http://localhost:1337'),
})
// config/middlewares.js
module.exports = [
'strapi::logger',
'strapi::errors',
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'img-src': ["'self'", 'data:', 'blob:', 'res.cloudinary.com'],
},
},
},
},
{ name: 'strapi::cors', config: { origin: [process.env.FRONTEND_URL] } },
'strapi::poweredBy',
'strapi::query',
'strapi::body',
'strapi::session',
'strapi::favicon',
'strapi::public',
]
API Token
# Create via Admin: Settings → API Tokens → Create new API Token
# Type: Read-only / Full access / Custom
# Copy token — shown only once
Frontend .env:
STRAPI_URL=http://localhost:1337
STRAPI_API_TOKEN=your-api-token-here
Production Deployment
# Build
NODE_ENV=production npm run build
NODE_ENV=production npm start
# PM2
pm2 start ecosystem.config.js
// ecosystem.config.js
module.exports = {
apps: [{
name: 'strapi',
script: 'npm',
args: 'start',
env: {
NODE_ENV: 'production',
DATABASE_URL: 'postgresql://...',
APP_KEYS: '...',
API_TOKEN_SALT: '...',
JWT_SECRET: '...',
},
}],
}
Timeline
Installation with PostgreSQL, basic configuration, and first content type takes 2–4 hours.







