Deploy Node.js Express with DeployHQ
This guide will show you how to automate deployments of your Node.js Express project using DeployHQ.
Prerequisites:
- A hosted server with Node.js and npm installed.
- A Node.js Express project
DeployHQ Setup
Create a Project:
Sign up and log in to DeployHQ. Go to Projects > New Project. Follow the wizard to connect your project repository.
Server Configuration:
Go to Servers > New Server.
Choose a name and select SSH as the protocol.
Enter your server's IP address and username (usually deployhq
).
Enable Use SSH key rather than password for authentication?.
On your server, run the following commands (replace deployhq
with your username if different):
sudo adduser deployhq
sudo usermod -a -G www-data deployhq
su - deployhq
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
Paste DeployHQ's public key into the nano
editor. Save (Ctrl+X
, Y
, then Enter
).
Set permissions:
chmod 600 ~/.ssh/authorized_keys
Set the Deployment Path to your project's directory (e.g., /var/www/your-app
).
Enable Perform zero-downtime deployments on this server (optional).
Set the Environment to production
and enable Automatically deploy.
Save the server configuration.
Config Files (Optional):
Go to Config Files and add any sensitive files (e.g., .env
) that you don't want in your repository.
SSH Commands:
Go to SSH Commands and add new commands:
- Install Dependencies:
cd %path% && npm install
- Start Application:
cd %path% && npm start
(or your specific start command, maybe should be better to start it using pm2)
Deployment
- Click Deploy Project in the header.
- Select your server and deployment options.
- Click Deploy to start the deployment process.
Congratulations! You've automated deployments for your Node.js Express project with DeployHQ.
If you’ve got any other projects you’d like to automate deployments for, we’ve written lots of guides for deploying the most popular application frameworks and content management systems.