
Using Git Version Control in cPanel to Deploy Node.js Projects
Using Git Version Control in cPanel to Deploy Node.js Projects
Git is an essential tool for modern software development, allowing you to track changes, collaborate, and deploy applications efficiently. Many hosting providers, including Hiverift, integrate Git functionality directly into cPanel, making it easy to deploy your Node.js projects with version control.
Why Use Git in cPanel for Node.js Deployment?
- Seamless deployment: Pull code directly from your remote Git repository onto your hosting server.
- Version control: Maintain history and rollback if needed.
- Collaboration: Multiple developers can push changes to the repository.
- Automation: Streamline updates by pulling the latest commits without manual uploads.
Prerequisites
- Active Hiverift hosting account with cPanel access
- Node.js installed and configured on your hosting environment
- Git repository hosted on platforms like GitHub, GitLab, or Bitbucket
- SSH or password access for cPanel to connect to Git remotes if needed
Step 1: Access Git Version Control in cPanel
- Login to your Hiverift cPanel dashboard.
- Locate the Git Version Control feature under the Files section.
- Click Create to start a new repository deployment.
Step 2: Clone Your Remote Repository
In the Git Version Control panel:
- Enter the Clone URL of your remote Node.js project repository (HTTPS or SSH link).
- Choose the directory path where the repository will be cloned on the server (e.g.,
~/my-node-app
). - Click Create or Clone to begin cloning.
Step 3: Manage Your Repository
Once cloned, cPanel provides options to:
- Pull the latest changes from the remote repository
- View repository details and branches
- Delete the repository if needed
Use the Pull button after making changes in your remote repo to update your server code instantly.
Step 4: Install Dependencies via SSH or cPanel Terminal
Open your SSH terminal or the cPanel terminal and navigate to your project directory:
cd ~/my-node-app
Install all Node.js dependencies defined in package.json
by running:
npm install
Step 5: Start or Restart Your Node.js Application
Depending on your setup, use one of the following methods to run your app:
- Use cPanel’s Node.js Application manager to set the application root and startup file and start the app.
- Or run your app with
pm2
if installed, e.g.,
pm2 start server.js --name my-node-app
Step 6: Automate Future Deployments
After making code changes and pushing to your Git remote:
- Login to cPanel.
- Go to Git Version Control.
- Find your repository and click Pull to fetch and merge the latest commits.
- SSH into your server and run
npm install
if dependencies changed. - Restart your Node.js app to apply updates.
Troubleshooting Tips
- Authentication errors: Make sure your SSH keys or credentials are set correctly for private repos.
- Pull fails: Check for merge conflicts or permission issues on the server directories.
- App not running after deployment: Review logs with
pm2 logs
or check cPanel error logs.
Conclusion
Using Git version control in cPanel to deploy your Node.js projects on Hiverift hosting makes development and deployment streamlined and professional. It empowers you to manage code versions, collaborate efficiently, and keep your live application up-to-date with minimal effort.