I am trying to delpoy strapi project to shared host but always have same message
Error Capture
have anyone uploaded strapi to cpanel give me the right way to deploy it
steps I made :
1-build project
2-made app.js file
3-add db
4-create node app (but also give error on npm install I don’t now what the error so uploaded the node_moduls)
any one have any ideas about this problem
2
Answers
Took me a few days to get this figured. This is what I got working:
1st (failed) attempt was setting up a
node.js
app in CPanel as a folder under the domain. i.e.domainname.com/CMS
. This would not route properly, no matter what I tried. Kept throwing 404s.2nd (successful) was using a subdomain.
Three main steps:
cms.domainname.com
Register a CNAME
Make sure your domain is configured with a CNAME record pointing at
cms.domainname.com
Configure and Build
CPanel – Domain config
Under CPanel domains click
Create a New Domain
Configure your domain and save it
CPanel – Create and configure
ftp
the build artifacts later.The file structure of your folder on the server should look like this:
server.js
.env
package.json
Just make sure it has the latest npm packages and the standard script commands:
Logging (optional)
If you want logging enabled:
winston
:npm i winston
./config/logger.ts
with the following:Build (through ssh)
npm i --omit=dev
npm run build
npm start
That should do it. You might need to access the application through the CPanel
nodejs
application dashboard and explicitly start it through the UI.Would you please specify where did you get the ‘dist’ folder from, since strapi has ‘build’ folder, at least v4.24.4?
I have a local mysql db which I’ve used to run strapi locally, and initialize the admin panel and add some data.
I then logged to cpanel, made a fresh db and connected a user to it, and imported my local mysql db to the cpanel db.
Then I changed my .env file to correspond to the cpanel parameters and built the app locally (with NODE_ENV=production).
I uploaded the .zip of all local app files (except the node modules) and unpacked it.
Then I created nodejs app and added your server.js file, both to the folder (creating a new file) and as an application startup file in the create node app UI.
And nothing happens when I start the app and visit my domain.
Any idea what I might be missing here?
Anyways, you did a great work if you made this running on a cpanel.