Deploy Strapi on Plesk
I found it a little bit tricky to release Strapi on Plesk so I want to share my experience with those who, like me, prefer to avoid releasing in AWS, Azure, or Digital Ocean and want to stay with a Plesk Managed Ubuntu or Centos server.
1 So, the first thing to do is create a server.js file in the application root with the following code:
const strapi = require('@strapi/strapi');
strapi().start();2 Create a domain on Plesk, or use the root of an existing domain and upload your Strapi application to it. You can do it by FTP, using file manager, or you can configure automatic deployment from GitHub, it doesn’t care, just find your preferred way.
3 If you don’t already have it, install the Node.js extension in Plesk. Go to “Extensions”, search, and install Node.js
4 Go to the Dashboard of your domain, then in Node.js and configure your applications as follows:
- Node.js Version: 16 or 18 (Strapi requires an even version)
- Package Manager: npm or yarn (Depending on what you’ve used in development)
- Document Root: the root of your project
- Application Mode: production
- Application Root: the root of your project
- Application Startup File: server.js (the file created on point 1)
5 Click on “npm / yarn install” to install all your project dependencies, and wait until the process is finished.
6 Click on “run script”, and a modal window with a textarea appears, paste “build” and hit “run”.
7 Restart your node application and that’s all.
I configured an automatic deployment directly from the “main” branch on my GitHub repo, maybe next time I’ll cover that part.
Interested in installing Strapi on cPanel instead of Plesk? Check out my guide on how to install Strapi on cPanel (article in Italian).
