How do I deploy a MERN application on a godaddy VPS

The only experience I have with deploying something is via git onto Heroku. How do I deploy an entire website onto a go daddy VPS?

I downloaded puTTY(SSH) and was able to connect to the server, from there I installed nvm and it’s now allowing me to use node and NPM. If I use the ls command from the bash terminal it doesn’t show any files. How do I actually upload my project onto the server and have them displayed on the website?

doing it with git and Heroku was easy I just created a Heroku link, logged in and pushed my application with GIT.

I’d like to deploy a basic MERN website to a GoDaddy VPS and have it displayed on the intended domain but I’m sort of lost at this point.

I have no experience with GoDaddy VPS, but it sounds like you get a VM/Machine that is your server, which is common with few hosting services out there.

The good thing is you can do whatever you want, the bad thing is choosing what. The easiest thing you usually can do is use git to clone your repository into the VPS machine, and setup everything from there. You have complete control over this sort of setup usually.

Alternate approaches could be installing some software to do some deployment management, either on the VPS or an external service.

The general idea is if you have a machine sitting in the corner of your room, how would you setup your application on it to run “in production”? That’s about the level of complexity your looking at. Your welcome to look up specific guides for your MERN stack, and how to manage one in production.

Goodluck :smiley:

I’d go with the easy route and be fine with just cloning from my repo to the vps. I have found pretty much no tutorials with how to go about this.

I have an Idea. Could I upload the entire application through ftp like filezilla then just NPM run start through the SSH?

1 Like

I believe ftp is an option, this way your machine doesn’t need credentials to access your git source, so yes you could go that route.

Do you have CPanel on your account?

The part that tripped me up the most, was getting the .cpanel.yaml file working correctly. This file is a list of commands that will run, upon successful git push to production.

I have mine set up so that I can git push PROD to production:

git remote add PROD ssh://<username>@<>:<port#>/home/<username>/git-<username>

which pushes to a folder outside of my public_html folder on my VPS. Then the .cpanel.yaml file runs which has commands setup to copy from the git-<username> folder over to the public_html folder (among other things). You can run shell scripts and anything else you can run on the command line from here too (such as npm run build or npm run start).

    - export DEPLOYPATH=/home/<username>/
    - /bin/cp -R /home/<username>/git-<projectname>/build $DEPLOYPATH

CPanel has installed with git for quite some time, but only more recently, was git added to the CPanel GUI - and FINALLY they upgraded from version 1 of git!

Please note that the /home/ up above, may be in a different location on your VPS! And this isn’t the complete setup, just something to get you started if you are using CPanel.

If not, there is something similar you can do with webhoooks - but I could never git mine working correctly:

1 Like

using git clone is one way, another with ssh is to use scp.

scp -r ./ the -r flag is for recursive to allow directories. This would be run from your machine, not theirs.

FileZilla should also work I believe, haven’t used it in some time though.

On your server you might want to install something like pm2 to keep your app running. but this will likely mean that your app will not be running on port 80, but you can aslo setup nginx to port foward to your app.

There are honestly probably something like a dozen ways you can do this including using containers with something like docker.

All that said honestly if you don’t take the time to learn your way around a linux shell your simplist way to go about it is to setup a domain with GoDaddy or another service and set up heroku to use that domain for the site.

I personally use Digital Ocean for my website, have it setup with nginx a SSL cert through LetsEncrypt and use docker for deployment. Its honestly taking me awhile to get even a minor grasp on some of this.

That said the documataion on Digital Ocean for doing varius things with it are great and can walk you through doing a fair bit, and may even help with GoDaddy’s VPS. I don’t know what type of linux environment GoDaddy uses though.

If you, or anyone else would like I can send a referal link that gives you $100 credit to play with for DigitalOcean, just send me a pm and I’ll get back to you.

Thank you all this information was exactly what I was looking for.

Man learning my way around a Linux based shell is like learning something completely new. I feel like I need to take a whole course on this stuff… it’s taken me all weekend just to get this thing on the domain.

I’ve been able to solve problem after problem but just trying to do something as simple as install an SSL certificate is pretty complicated or adding WWW to my website domain

I’m using nginx on CentOS 6