3

I'm setting up a Strapi install in my Apache cPanel (WHM on CentOS 7), and can't find a proper way to deploy it. I've managed to get it running, but when I try to access the dashboard (/admin), it just shows the index page (the one in public/index).

Is this the proper way to deploy Strapi to an Apache server?

Is the "--quickstart" setting only for testing purposes, or can this be used in Production? If so, what are the pre-deployment steps I need to take?

This is for a simple project that requires easy to edit content that will be grabbed via API manually from another cPanel installation.

Reading through the Strapi docs, I could only find deployment information about Heroku, Netlify and other third-party services such as these, nothing on hosting it yourself on Apache/cPanel.

I've tried setting up a "--quickstart" project locally, getting it working and then deploying via Bitbucket Pipelines. After that, just going into the cPanel terminal and starting it - though the aforementioned problem occurs, can't access admin dashboard.

Here's my server.json configuration:

Production

{
  "host": "api.example.com",
  "port": 1337,
  "production": true,
  "proxy": {
    "enabled": false
  },
  "cron": {
    "enabled": false
  },
  "admin": {
    "autoOpen": false
  }
}

Development

{
  "host": "localhost",
  "port": 1337,
  "proxy": {
    "enabled": false
  },
  "cron": {
    "enabled": false
  },
  "admin": {
    "autoOpen": false
  }
}

There are no console errors, nor 404s when trying to access it.

Edit

Regarding deployment with the --quickstart setting:

there are many features (mainly related to searching) that don't work properly with SQLite (lack of proper index support) Not to mention the possible slowness due to disk speed and raw IOPS of the disk.

A suggestion on how to implement:

Respectfully, to deploy strapi you likely need to: 1. build a docker container for it 2. make a script to deploy it 3. use SSH and do it manually 4. use a CI/CD platform and scripted to deploy it

In summary:

Strapi is not your typical "copy the files and start apache" it's not a flat file system, Strapi itself is designed to be run as a service similar to Apache/Nginx/MySQL ect. They are all services (Strapi does need Apache/Nginx/Traefik to do ssl for it though via proxying)

Rom Filippini
  • 31
  • 1
  • 3
  • Have anyone done this successfully on Centos with WHM/Cpanel? As suggested used Docker scripts, Or in other way? – Ram Dec 20 '21 at 17:22

1 Answers1

1

If you have the index page when you visit /admin it's because the admin is not built.

Please run yarn build before starting your application.

Jim LAURIE
  • 3,859
  • 1
  • 11
  • 14
  • I did that - probably should've mentioned in the post. But then, it wouldn't give me a login screen, it would give me the "Register your first admin" screen, even though I had already created one in local development. – Rom Filippini Sep 05 '19 at 10:03
  • Which post are you talking about? To let me be able to make an update. For the login screen, what is the database you use in development and production environment? In this case, it will depend on your database configuration and the env you use to start your application. – Jim LAURIE Sep 16 '19 at 09:21
  • Hi Jim, apologies, I meant that I should've mentioned in my question ("post") that I tried running the build command. As for the database configuration, I simply ran the "quickstart" mode which, from reading the Strapi docs, seemed to me it should just work. But on the Strapi slack channel I was told that the "quickstart" runs SQLite which isn't appropriate for production builds. – Rom Filippini Sep 17 '19 at 10:29
  • You will be able to switch on another SQL database for your production environment. By updating your `./config/environments/production/database.json` file. – Jim LAURIE Sep 19 '19 at 12:36