Planning to go with SiteGround or have already purchased it? Now, you are wondering, “Does SiteGround support NodeJS?”.
We will see whether it’s officially supported or not. We have a small surprise for you even if the answer is no.
Let’s not wait and get the guide to start with the answer.
Does SiteGround support NodeJS?
No, SiteGround doesn’t support NodeJS, not even their cloud hosting supports it. However, there is a small hack for you to run NodeJS apps on SiteGround.
Setting Up Node.js on SiteGround
Surprise! We will tell you how you can install and run NodeJS on SiteGround if they don’t allow it.
Step-by-step guide for configuring Node.js on SiteGround
Here are some easy steps to set up NodeJS on SiteGround hosting with ease.
Step 1: Generate SSH Key Pair
Of course, the first step is generating an SSH key.
You can also create an SSH key from the SiteGround panel. Head over to SSH keys manager and click on “Create”. Enter a key name and passphrase.
Now, hit the “Create” button. You have your keys now.
Another traditional way is to do it from your computer. If you follow the above one, you don’t need to do this.
You will have to open your terminal on your local machine and generate an SSH key. Enter the following command to generate the keys.
ssh-keygen -t rsa -b 4096 -C “[email protected]“
Not to mention, you will have to replace the email address with your original one. Now, you will be prompted to save the file. As of now, you can select the default location and proceed.
Note that location as we will need to upload the generated file in the next step.
After that, the next step is to enter a passphrase. You can enter one or leave it blank. Please note that it will still appear blank (hidden) even if you type it.
So, you can press the keys and move on.
Step 2: Add SSH Key to SiteGround
This step is for the people who have created the key using a local machine.
Now, it’s time to open your SiteGround account and open the SiteGround panel. You will see the “Public keys” section. Under that section, you can hit the “Import key” button.
Now, you will have to upload the .pub (pub stands for public key) file generated in the above step. You will see that the import button just has a field.
In that case, you can open the .pub file with a text editor (Notepad will work fine) and copy-paste the content.
Make sure you copy it in the “public key” field. You can enter any name of the key and then click on the “Import” button.
Step 3: Connect to SiteGround via SSH
If you are an expert, you can use Putty software to connect. Otherwise, you can follow the traditional way.
Open your terminal on the local machine.
Type the following command on your machine where you replace the username with your SiteGround username and domain with your domain name or IP.
For first-time users, you will be asked to confirm the authenticity and then you will have to enter the passphrase. That’s it, you have connected the terminal with the SiteGround server via SSH.
Step 4: Set Up Node.js Environment
Let’s see if Node.js is already installed on your SiteGround. Run the following command to find out.
You can use NVM (Node Version Manager) to install Nodejs if it’s not installed.
Type in the below command to install the node using NVM. Feel free to replace the version name.
nvm install node 13
If you get a message saying NVM is an unknown command, you can install NVM using the following command. Feel free to replace the nvm version name.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Thereafter, you can run the above command.
Step 5: Deploy Your Node.js Application
You can now upload your NodeJS application to your SiteGround account via file manager or FTP.
Navigate to your app directory using the following command.
Your NodeJS app might have dependencies. You can install it using the following command.
To start your NodeJS app, you will have to use Process Manager. You can use the following command to start the app js file. Make sure you replace the app.js file with the entry point of your NodeJS application.
pm2 start app.js
That’s pretty much it. Your Nodejs app is now running on SiteGround.
Optimizing Node.js Performance on SiteGround
It’s important to optimize NodeJS performance on SiteGround as SiteGround doesn’t officially support NodeJS.
- Start with the caching mechanism. It reduces server load and provides better response time for regular visitors.
- Minify or bundle front-end assets.
- Gzip compression enables you to reduce data transfer and thus improves speed.
- Optimize database queries. Try adding database Indexes and caching configurations to speed up lookups.
- Implement load balancing on your server. SiteGround CDN 2.0 will help here.
- Keep monitoring the server. Find bottlenecks and optimize them.
- Middleware and third-party modules are resource stealers. Make sure you regularly review and optimize them.
To summarize, SiteGround doesn’t officially support NodeJS. So, you will have to install it via SSH by the steps that are mentioned in this guide.
There might be a few compatibility issues as they do not officially support it. It’s best to get a VPS if you want complete support for NodeJS. If you think VPS is expensive, you can opt for a cheap VPS service or a shared hosting provider that supports NodeJS.
FAQ (Frequently Asked Questions)
It depends on the hosting providers. In some cases, the hosting provider allows you to host a Nodejs app.
Which server supports node JS?
Many servers are supporting NodeJS including A2Hosting, and Dreamhost. You can also work around your way with SiteGround.
Where can I deploy node JS for free?
You can deploy NodeJS for free. However, you will have to pay the server charges.
Can we host node JS in cPanel?
cPanel is just a way to manage your server. So, it will depend on your web server whether you can use NodeJS or not.
Can I host NodeJS on HostGator?
HostGator shared hosting doesn’t allow NodeJS. However, it can be installed in VPS.