I signed up for the free trial of the google cloud platform, and I'm stuck. My application is a node server using express. It needs to connect to a mongodb cluster. I just need to be able to serve a couple of pages. How could I do this using the compute engine. Is there a really simple tutorial to follow to deploy my app? I can't use the app engine because managed vms aren't available in Europe. Thanks.
2 Answers
Deploying a node.js app to Google Compute Engine really isn't all that different from deploying it on any other Infrastructure as a Service provider.
Try one of the following tutorials:
- https://gun.io/blog/tutorial-deploy-node-js-server-with-example/
- https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04
- https://strongloop.com/strongblog/node-js-deploy-production-best-practice/
You'll need to spin up a Google Compute Engine VM instance, of course, to deploy to.
You can do this using the gcloud compute instances create
command:
gcloud compute instances create --image ubuntu-14-04 --machine-type n1-standard-1 your-instance-name
Then, connect via gcloud compute ssh
:
gcloud compute ssh --zone [zone you created your instance in] your-instance-name
You can also do both of these steps from the Cloud Console.

- 20,014
- 4
- 39
- 37
-
I went to the "cloud launcher" and created a vm with bitnami. How can I tell the server to run my application code? – Rockstar5645 Sep 25 '15 at 14:41
-
That sounds like a Bitnami issue, which is best addressed in another SO question. – Zachary Newman Sep 25 '15 at 14:45
-
1As you can see from https://cloud.google.com/launcher/solution/bitnami-launchpad/nodejs?q=node, Bitnamit provides support for their images via their community site: https://community.bitnami.com/ – Misha Brukman Sep 25 '15 at 15:39
-
@Zachary the first blog is a bit dated and the last one isn't a tutorial, it's a list of suggestions. I went through digitalocean tutorial but the ssh on compute engine is really slow and I'm not familiar with ubuntu commands. Is there a tutorial for setting up a node server using windows operating system vm? – Rockstar5645 Sep 25 '15 at 16:19
-
My hunch is that if ssh to a GCE Linux VM is slow, remote desktop to a GCE Windows VM will be slower, but you're welcome to try. You can look into [iisnode](https://github.com/tjanczuk/iisnode) or [this alternative solution](http://dvisagie.blogspot.com/2013/02/running-nodejs-alongside-iis-on-windows.html). – Zachary Newman Sep 25 '15 at 17:03
-
@Rockstar5645 — You can use [another Linux distro](https://cloud.google.com/compute/docs/operating-systems/) if you prefer Debian, CentOS, RedHat or SUSE over Ubuntu. Note that RedHat and SUSE are premium images and carry an additional software license cost. Debian, CentOS, and Ubuntu are free from the software licensing perspective, but note that GCE VM cost still applies in all cases. – Misha Brukman Sep 25 '15 at 18:44
-
I want to use windows os, how can we install node on the vm? – Rockstar5645 Sep 26 '15 at 16:07
I just want to share one of my deployment experience. I found it's the most easy way in all the tutorials I see.
I use google cloud launcher to launch a Bitnami VM, MEAN Stack in my case. They also have a node.js solution.
Then you can follow this tutorial Bitnami Custom Node.js Application. Basically five steps :
create the basic application directory structure under /opt/bitnami/apps.
apps/myapp
|- conf
|- htdocs
|- data (optional)
put the application code in htdocs folder
- edit the configuration file
start the application
sudo /opt/bitnami/nodejs/bin/node /opt/bitnami/nodejs/bin/forever start myapp.js
or if you use express generated project :
sudo /opt/bitnami/nodejs/bin/node /opt/bitnami/nodejs/bin/forever start ./bin/www
restart the Apache server to refresh new configuration
sudo /opt/bitnami/ctlscript.sh restart apache

- 479
- 2
- 6
- 21