Deploy Strapi on cPanel


Hi, I try to deploy my strapi project on cpanel. I use the “Setup Node.js App” software, but I can’t run “strapi develop”. I upload my files and everything work except the CONTENT-TYPE BUILDER because it needs to start the server with “strapi develop”. I tried to use the option “Run The Script” on cpanel but I wait 20 minutes now and nothing change. I am a beginner with strapi so I am not sure what is wrong

2 Likes

I have been struggling with setting up my Strapi project on Cpanel myself. Can’t even see the login or create user page.

2 Likes

Hey did you get any solution yet?

I find a semi-solution, use VSCode and connect ssh with it to webhost/cpanel then stop app(because conflict) run strapi (npm run develop[package.json script]) on localhost:port (ex:localhost:1337 on your webhost) use port forwarding and forward the port 1337 then you can open in your browser from localmachine
for more info : Connect over SSH with Visual Studio Code

deploy without Setup Node.js Deploy Node.js Apps To Shared Hosting - YouTube

Cpanel on default creates a ‘app.js’ file on the directory root
if not create a js file and set it as application startup file

open that file and remove everything and replace with this:

const strapi = require('@strapi/strapi');

if (process.env.NODE_ENV == "development")
    strapi({"autoReload": { "enabled": true }}).start();
else
    strapi().start();

now if you set your application mode to development you will be able to use content-type builder [ cuz I added that condition in the script ] :wink:

now you can save and start the app and everything will work as expected. you can now create category while in development mode

2 Likes

perform a npm run build in your local environment. after that copy the build file to cpanel node app root directory.

your solution was amazing, thank you

Hey apostolis_dimitriou, im curently trying to host the admin panel on Cpanel but the error “500 internal servor” can you show me all you need to make strapi working in developement and Production please ?

Thank you in advance !

hi there

i’ve copied the build folder onto cpanel root directory in my case i’ve created a folder called ‘admin’.
When i go to that url mydomian/admin, i get error “Warning An error occurred while requesting the API” and nothing happens just the loading spinner spinning forever.

any help is much appreciated,

thanks in advance