-
Notifications
You must be signed in to change notification settings - Fork 0
Strapi application setup
For a Strapi application, we use pm2 for deployment. This will create a node instance on the server. The create_strapi_site command will add the required configuration to nginx. In the current set-up there is no support yet for multiple Strapi running on the same server. But this can easily be achieved by modifying the create_strapi_site so it will prompt for the right port number. This port number should then be equal to the PORT number in the .env file.
-
Login to the remote server
ssh <user>@<host>. Make sure that you are using the sameuseras you define in your local.envfile. -
Create an ssh key
cd ~/.ssh
ssh-keygen -f github_<github_username>_<repo> -t ecdsa -b 521
Replace <github_username> with the username that the repo belongs to, and replace <repo> with the name of the repo.
3) Update (or create) ~/.ssh/config file
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_<github_username>_<repo>
If this code already exists, you can copy the IdentityFile line, and use your newly created keyfile
- Add ssh key to the list of deploy keys of your repo
Go to your repo, and go to
settings > deploy keys > add deploy key. For the title use @, and paste the contents of~/.ssh/github_<github_username>_<repo>.pubhere. Leaveallow write accessunchecked!
These are all the required steps needed for pm2 to be able to setup the deployment flow.
- Download the
ecosystem.config.jsfile and place it in the root of your project. - Run
pm2 deploy production setup
DEPLOYMENT_USER=<user>
DEPLOYMENT_HOST=<host>
DEPLOYMENT_PATH=/var/www/strapi/<project>
DEPLOYMENT_REPO=git@github.com:<github_username>/<repo>.git
- Replace the
userwith the username required to login to the remote server. - Replace
hostwith the name of the server (no www, https or other prefixes, ip address could be fine as well) - Replace
projectwith the name of the directory that you want to install the project - Replace
github_username&repowith the same properties of the repo where you added the deploy key to
-
Copy .env file to remote server
scp .env <user>@<host>:/var/www/strapi/<project>/source -
Test if deployment works
pm2 deploy ecosystem.config.js production --force