Deploying a Ghost Project with DeployHQ
Deploying a Ghost Project with DeployHQ
Prerequisites:
- A hosted server with Node.js and npm installed.
- A Ghost project ready for deployment.
- A DeployHQ account.
Using DeployHQ for Ghost Deployments
DeployHQ simplifies the deployment process for Ghost, automating builds and deployments.
Creating a DeployHQ Project
- Sign up and log in to your DeployHQ account.
- Create a new project:
- Go to Projects > New Project.
- Follow the wizard to connect your Git repository.
Configuring a Deployment Server
- Create a new server:
- Go to Servers > New Server.
- Name the server.
- Select SSH as the protocol.
- Enter the Hostname (server IP address).
- Set the Username (e.g.,
deployhq
). - Enable SSH key authentication:
- On your server, run:
su - deployhq
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
- Paste DeployHQ's public SSH key into the file.
- Save and close the file.
- Set permissions:
chmod 600 ~/.ssh/authorized_keys
- Set the Deployment Path: Specify the directory where your Ghost project will be deployed.
- Enable zero-downtime deployments: This ensures smooth deployments without downtime.
- Set the Environment: Enter
production
. - Enable automatic deployment: This triggers a deployment whenever there's a code change.
- Save the configuration.
Configuring SSH Commands
- Create new Commands in the Build Pipeline:
# Install dependencies
cd %path% && npm install --production
# Build the Ghost project
npm run build
- Create new SSH Commands :
# Restart Ghost (If using a process manager like PM2)
pm2 restart ghost
# If using a systemd service
sudo systemctl restart ghost
Deploying Your Ghost Project
- Click "Deploy Project" in the header.
- Select the server and revision to deploy.
- Click "Deploy" to initiate the deployment process.
Additional Tips
- Configure environment variables: Use DeployHQ's configuration files to securely store sensitive information like database credentials.
- Leverage custom scripts: Create custom scripts for more complex deployment tasks, such as database migrations or custom configuration changes.
- Monitor deployments: Keep track of deployment statuses and logs to identify and resolve issues promptly.
By following these steps and customizing the configuration to your specific needs, you can effectively automate your Ghost deployments with DeployHQ, ensuring smooth and reliable updates to your website.