Is there documentation on how to deploy and setup strapi with a VPS with Ubuntu 20.04?

System Information
  • Strapi Version: The recommended one.
  • Operating System: Ubuntu 20.04
  • Database: PostgreSQL
  • Node Version: The recommended one.
  • NPM Version: The recommended one.
  • Yarn Version: The recommended one.

Is there documentation on how to deploy and setup Strapi with a VPS with Ubuntu 20.04?

I want to use Strapi as CMS, but I would like to use my VPS for the deployment etc.

  1. Put your project in git

  2. On VPS install:

  3. Clone your repo to vps

  4. Run yarn install --production=true inside the project

  5. Build the project with NODE_ENV=production yarn build

  6. Run it with pm2.

  7. Configure nginx to proxy requests all requests from 80/433 to 1337(or what port you defined in strapi envs)

Done.

Also, take a look at this article, it’s pretty similar to strapi’s deployment.

3 Likes

@piwi maybe we should have a generic Linux deploy guide and link the specific providers to that? In terms of actual Linux implementation almost every cloud VPS is functionally the same (minus AWS and how they handle the root user account).

Keep provider specific guides to just their interface differences :thinking:

3 Likes

Could be a great idea, yes, thank you for the suggestion!
Adding this to my todo list.

2 Likes

I built it locally, can I skip step 4 and 5?

Step 4, is kinda recommended because it will not install all the dev dependencies in production.

Step 5, is not mandatory, but is also recommended to build the project with production configuration.

Step 5, can I do it with a build in the folder or do I need to delete the previous build folder?
Got this error:
`$ NODE_ENV=production yarn build
yarn run v1.22.10
$ strapi build
Building your admin UI with production configuration …

● Webpack β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ recording (91%)

<β€” Last few GCs β€”>

[55568:0x586b120] 162309 ms: Mark-sweep (reduce) 488.2 (491.9) -> 487.8 (493.6) MB, 1434.5 / 0.0 ms (+ 289.8 ms in 36 steps since start of marking, biggest step 65.2 ms, walltime since start of marking 1935 ms) (average mu = 0.318, current mu = 0.343) [55568:0x586b120] 164697 ms: Mark-sweep (reduce) 488.9 (495.6) -> 488.0 (495.9) MB, 2384.5 / 0.0 ms (average mu = 0.165, current mu = 0.001) allocation failure scavenge might not succeed

<β€” JS stacktrace β€”>

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa04200 node::Abort() [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
2: 0x94e4e9 node::FatalError(char const*, char const*) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
3: 0xb7978e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
4: 0xb79b07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
5: 0xd34395 [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
6: 0xd34f1f [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
7: 0xd42fab v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
8: 0xd46b6c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
9: 0xd1524b v8::internal::factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
10: 0x105b23f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
11: 0x1401219 [/home/edvhoi/.nvm/versions/node/v14.16.1/bin/node]
Aborted (core dumped)
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

The problem is that I have 1gb ram and not 2gb on the server. Is there any work around this?

No the build step requires 2GB of RAM, if you have to build on the server then you need 2GB of free ram. The only alternative would be to build locally or in a CI/CD and commit the build folder into the source control.

1 Like