How to Deploy a Node.Js Application on AWS Lightsail

 

In this tutorial, we will teach you how you can deploy a nodejs application on Amazon Web Services (AWS) Lightsail. We will first explain these terminologies like  node.js, and AWS Lightsail so let’s get started

 

Node.js is a server-side platform built on Google Chrome’s JavaScript Engine (V8 Engine). It’s is an open-source, cross-platform runtime environment for developing server-side and networking applications. Node.js applications are written in JavaScript and can be run within the Node.js runtime on Mac OS X, Microsoft Windows, and Linux.

Lightsail is an amazon web service for developers who need to build websites and web applications. You can choose an image for your Lightsail instance that jumpstarts your dev project so you don’t have to spend as much time installing software or frameworks. 

Instances in AWS are virtual environments. It’s an on-demand service, which means a user can rent the virtual server(instances) that has all the operating systems and software installed and deploy their applications on it.

Lightsail has images with base operating systems, development stacks like LAMP, LEMP (Nginx), and SQL Server Express, and applications like WordPress, Drupal, and Magento.

It includes everything you need to launch your project quickly – instances (virtual private servers), container services, managed databases, content delivery network (CDN) distributions, load balancers, SSD-based block storage, static IP addresses, DNS management of registered domains, and resource snapshots (backups) – for a low, predictable monthly price.

The first thing you need to do is open your project or application in your preferred Integrated Development Environment(IDE). We are using WebStorm for this particular application.

node js project opened in webstorm

Lightsail makes database administration more efficient by managing your common maintenance and security tasks. You can create your Mysql database by following the steps given here.


Once the database is created you need to connect and configure it. you can use any standard MySQL client application or utility to connect to it.You can connect your Mysql database by following the steps given here.

To set up your project you first need to login into the AWS account and go to the Lightsail dashboard and then perform the following steps.

Login and Create Instance

 

  • Click on create an instance.
  • Select a platform Linux/Unix.
  • Select a blueprint Apps + OS (checked by default) Select: Node.js (14.16.1).
  • Click Change SSH key pair Select existing key pair or create a new one.
  • Choose your instance plan for example USD 4.5.
  • Identify your instance (Your Lightsail resources must have unique names.) eg: firstnode_app.
  • Click on Create instance button.

Connect and Configure the Instance 

Once the instance is created you have to click on the terminal icon to connect instance and write the following command in the terminal.

 cd stack 
cd apps
Sudo mkdir myapp
sudo mkdir /opt/bitnami/apps/myapp/conf
sudo mkdir /opt/bitnami/apps/myapp/htdocs
sudo mkdir /opt/bitnami/apps/myapp/htdocs
sudo nano /opt/bitnami/apps/myapp/conf/httpd-prefix.conf
  •  Add Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
sudo nano /opt/bitnami/apps/myapp/conf/httpd-prefix.conf Add Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
sudo nano /opt/bitnami/apps/myapp/conf/httpd-app.conf
Add ProxyPass / http://127.0.0.1:3000/

ProxyPassReverse / http://127.0.0.1:3000/
sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf
  • Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf

FileZilla is a powerful and free software for transferring files over the Internet. It is a very popular FTP client and is used by webmasters from all over the world. Here you can download FileZilla software.

We need this to transfer our files between our local computer and Linux instance on Amazon Lightsail. For this, we will connect our instance using SFTP (SSH File Transfer Protocol).To do this, we need to get the private key for our instance, and then use it to configure the FTP client.

Download, Install and Get the Public IP Address :

Download and Install the Filezilla from the link given above. Now get the public IP address of your instance. Login into the Lightsail console, and then copy the public IP address that is displayed next to your instance, as shown in the image.

 

Get the SSH key for your instance

Follow these steps to get the default private key for the AWS Region of your instance, which is required to connect to your instance using FileZilla.

Note: If you’re using your key pair, or you created a key pair using the Lightsail console, locate your private key and use it to connect to your instance. Lightsail does not store your private key when you upload your key or create a key pair using the Lightsail console. You cannot connect to your instance using SFTP without your private key.

  • Sign in to the Lightsail console.
  • Choose Account on the top navigation bar, and then choose Account from the drop-down.
  • Choose the SSH Keys tab.
  • Choose Download next to the default private key for the region where your instance is located.
  • Save your private key in a secured location on your local drive.

Configure FileZilla and connect to your instance

Complete the following steps to configure FileZilla to connect to your instance.

  1. Open FileZilla.
  2. Choose File, Site Manager.
  3. Choose New site, then give your site a name.
image of sftp configuration

4. In the Protocol dropdown, choose SFTP – SSH File Transfer Protocol.

5. In the Host text box, enter or paste your instance’s public IP address.

6. In the Logon Type dropdown, choose Key File.

7. In the User text box, enter one of the following default user names depending on your instance operating system:

  • Amazon Linux, Amazon Linux 2, FreeBSD, and OpenSUSE instances: ec2-user
  • CentOS instances: centos
  • Debian instances: admin
  • Ubuntu instances: ubuntu
  • “Certified by Bitnami” instances: bitnami
  • Plesk instances: ubuntu
  • cPanel & WHM instances: centos

Note: If you are using a different user name than the default user names listed here, then you might need to give the user write permissions to your instance.

8. Next to the Key File text box, choose Browse.

9. Locate the private key file that you downloaded from the Lightsail console earlier in this procedure, and then choose Open.

image of sftp configuration

10. Choose Connect.

You may see a prompt similar to the following example, indicating that the host key is unknown. Choose OK to acknowledge the prompt and connect to your instance.

Now You are successfully connected if you see status messages similar to the following example:

connected successfully

Locate the folder of the node.js application you create on your local machine. Select the folder and compress it to create a zip executable file.

Now in step 3 when we were configuring the instance we had created a folder named “myapp”. To upload your project you need to log into the Lightsail console. Once logged in you need to select the terminal of the instance you created and go to the folder you created or in our case “myapp” and upload the zip folder there.

Once the folder is uploaded you needed to unzip the folder containing your project.

Now you need to run the following commands in the terminal.

This command will restart the scripts on your server.

 

 sudo /opt/bitnami/ctlscript.sh restart apache  

After restarting the scripts you need to run the following command to install the node module.

 npm install    

Once installed we will start our application on the server by running this command.

 npm start

Now that everything is set up we will check if our application is successfully deployed or not. 

For that, you need to copy the IP address of the instance you created shown on your Lightsail dashboard. Copy the IP address and paste it into the URL bar of the browser.

If it’s successful this will appear upon loading

Now that our application is deployed we need to make sure that the process keeps running by itself even when we have closed our local machine. To do that you need to run this command in the terminal.

Forever start  bin/www

We have successfully deployed a Nodejs server on AWS using Lightsail service.  We hope you find this article helpful. Feel free to contact us if you need any help regarding this topic. Do let us know the topics you want us to cover in the comment section or reach out to us with your queries by clicking the contact form below.

351 thoughts on “How to Deploy a Node.Js Application on AWS Lightsail”

  1. Hi there! Do you use Twitter? I’d like to follow you if that would be okay.I’m undoubtedly enjoying your blog and look forward to new posts.

  2. Reynold Mcgregor

    This paragraph offers clear idea designed for the new visitors of blogging, that genuinelyhow to do blogging.

  3. Fantastic post however I was wanting to know if you could write a litte more on this subject? I’d be very grateful if you could elaborate a little bit more. Kudos!

  4. Good blog you have got here.. Itís hard to find high-quality writing like yours nowadays. I truly appreciate individuals like you! Take care!!

  5. Georgiana Patel

    Amazing things here. I’m very glad to look your article.Thank you so much and I am looking ahead to touch you.Will you please drop me a e-mail?

  6. Bradley Davies

    When someone writes an paragraph he/she keeps the plan of a user in his/her mind that how a user can know it. Thus that’s why this post is perfect. Thanks!

  7. I’m not sure where you’re getting your info, but good topic.I needs to spend some time learning much more or understanding more.Thanks for great info I was looking for this info for my mission.

  8. Thank you for every other excellent post. Where else may anyone get that type of information in such a perfect way of writing?I’ve a presentation next week, and I’m at the search for suchinfo.

  9. Humphrey Higgins

    Hi friends, its wonderful article regarding tutoringand fully defined, keep it up all the time.

  10. I?m not sure where you are getting your info, but good topic. I needs to spend some time learning more or understanding more. Thanks for magnificent information I was looking for this info for my mission.

  11. Asking questions are in fact fastidious thing if you are not understanding something totally, however this paragraph presents good understanding yet.

  12. I’m now not certain the place you’re getting your info, but good topic.I must spend some time finding out much more orfiguring out more. Thank you for great info I used to be in searchof this information for my mission.

  13. I’d must check with you here. Which isn’t something I often do! I enjoy reading a publish that may make individuals think. Also, thanks for allowing me to comment!

  14. Object eradication software

    fantastic points altogether, you simply gained a emblem new reader. What might you recommend about your submit that you simply made some days in the past? Any certain?

  15. I will immediately take hold of your rss feed as I can’t in finding your e-mail subscription hyperlink or e-newsletter service. Do you have any? Kindly allow me recognise so that I may just subscribe. Thanks.

  16. Thanks for every other great post. Where else may anybody get that kind of info in such a perfect method of writing? I’ve a presentation subsequent week, and I am at the search for such info.

  17. prosolution gel

    Greetings! Very useful advice within this post! It’s the little changes that will make the biggest changes. Thanks a lot for sharing!

  18. After looking at a number of the blog posts on your site, I really appreciate your way of writing a blog. I book-marked it to my bookmark webpage list and will be checking back soon. Please visit my web site as well and tell me your opinion.

  19. prosolution plus

    I do agree with all the ideas you have offered for your post. They’re really convincing and can definitely work. Nonetheless, the posts are very brief for beginners. Could you please lengthen them a little from subsequent time? Thanks for the post.

  20. Heya i’m for the first time here. I came across this boardand I find It really useful & it helped me out a lot. I hope to givesomething back and help others like you helpedme.

  21. premature ejaculation gel

    An interesting discussion is definitely worth comment. I do believe that you should publish more on this subject matter, it might not be a taboo subject but typically people do not discuss such subjects. To the next! Kind regards!!

  22. I’d have to verify with you here. Which is not something I normally do! I take pleasure in studying a submit that will make individuals think. Also, thanks for permitting me to remark!

  23. It’s truly a nice and useful piece of info. I am satisfied that you just shared this useful information with us. Please stay us informed like this. Thanks for sharing.

  24. Binaural beats meditation is a technique that utilizes rhythmic auditory stimuli to induce a state of relaxation and focus. By presenting slightly different frequencies to each ear, the brain perceives a third “beat” which promotes synchronization of brainwaves, fostering a meditative state. This practice aids in reducing stress and enhancing mental clarity.

  25. Right here is the perfect webpage for everyone who would like to understand this topic. You realize a whole lot its almost tough to argue with you (not that I personally will need to…HaHa). You definitely put a new spin on a topic which has been written about for decades. Great stuff, just great.

  26. After I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a remark is added I get 4 emails with the identical comment. Is there any method you may take away me from that service? Thanks!

  27. Helllo There. I found your blog using msn. This is a very well written article.I’llbe sure to bookmark it andd come back to read ore of your useful info.Thanks for the post. I’ll definitely return.

  28. My partner and I stumbled over here different website and thought I may as well
    check things out. I like what I see so i am just following you.

    Look forward to checking out your web page repeatedly.

  29. I like looking through a post that will make men and women think. Also, thank you for permitting me to comment.

  30. Greetings from Los angeles! I’m bored to tears at work so I decided to browse your
    site on my iphone during lunch break. I enjoy the info you present here and can’t wait to take a look when I get home.
    I’m amazed at how fast your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyways, awesome blog!

  31. Thank you, I have recently been looking for info about this topic for ages and yours is the greatest I have discovered so far. But, what about the bottom line? Are you sure about the source?

  32. I truly love your site.. Great colors & theme. Did you create this site yourself? Please reply back as I’m wanting to create my own site and want to know where you got this from or just what the theme is named. Appreciate it!

  33. Thank you for any other wonderful post. The place else could anyone getthat type of information in such a perfect manner of writing?I have a presentation next week, and I’m at the search for suchinfo.

  34. Wow that was strange. I just wrote an very long comment butafter I clicked submit my comment didn’t show up.Grrrr… well I’m not writing all that over again. Anyways, just wanted to say wonderful blog!

  35. Greetings! Quick question that’s entirely off topic. Do you
    know how to make your site mobile friendly? My weblog looks weird
    when browsing from my apple iphone. I’m trying to find a template or
    plugin that might be able to resolve this problem. If you have
    any recommendations, please share. Many thanks!

  36. I do accept as true with all the ideas you’ve presented on your
    post. They’re really convincing and will definitely work.
    Still, the posts are very short for starters.
    May you please extend them a little from next time? Thank you for the post.

  37. Hey There. I found your blog using msn. This is a reallywell written article. I will be sure to bookmark it and return to read more of your useful info.Thanks for the post. I will certainly comeback.

  38. It is the best time to make some plans for the long run and it is time to be happy.
    I have learn this post and if I could I desire to counsel you few fascinating things or tips.

    Perhaps you can write next articles relating to this
    article. I want to learn even more issues about it!

  39. Generally I do not read post on blogs, however I would like tosay that this write-up very pressured me to try and do it!Your writing style has been amazed me. Thank you, quite nice post.

  40. สล็อตออนไลน์เกมคาสิโนยอดนิยมชั่วกัลปวสาน เล่นง่าย แจ็คพอตแตกไวจะต้องที่ UFABET จ่ายจริง จ่ายเต็ม มีเกมให้เลือกจำนวนมากทั้งแทงบอล บาคาร่า ยิงปลา มาเว็บไซต์แห่งนี้เว็บเดียวบอกเลยนะครับผมว่าโคตรคุ้ม สร้างรายได้ง่ายๆจบที่เว็บไซต์ UFABET ได้เลยจ๊าขอรับ

  41. Easily, the post is really the greatest on this laudable topic. I concur with your conclusions and will thirstily look forward to your future updates. Saying thank will not just be sufficient, for the wonderful c lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates. Solid work and much success in your business enterprise!

  42. Hmm it looks like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what
    I had written and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to the whole thing.
    Do you have any tips and hints for rookie blog writers?
    I’d really appreciate it.

  43. Right here is the right webpage for anybody who hopes to understand this topic. You realize so much its almost hard to argue with you (not that I actually would want to…HaHa). You certainly put a brand new spin on a topic that’s been written about for ages. Great stuff, just great.

  44. I have been surfing online more than three hours today, yet
    I never found any interesting article like yours. It’s pretty worth enough for me.
    In my opinion, if all site owners and bloggers made good content as you did, the net
    will be much more useful than ever before.

  45. Thanks for some other great post. Where else may anybody get that kind of information in such an ideal method of writing? I’ve a presentation next week, and I am at the look for such information.

  46. This is the perfect site for everyone who wishes to find out about this topic. You understand a whole lot its almost hard to argue with you (not that I actually would want to…HaHa). You certainly put a brand new spin on a subject that has been written about for ages. Great stuff, just great.

  47. Thanks for discussing your ideas. I might also like to mention that video games have been actually evolving. Technology advances and innovative developments have made it simpler to create authentic and fun games. Most of these entertainment games were not as sensible when the real concept was being attempted. Just like other designs of technological innovation, video games also have had to develop by many generations. This is testimony towards the fast development of video games.

  48. Hey There. I found your blog using msn. This is an extremely well written article. I’ll be sure to bookmark it and return to read more of your useful info. Thanks for the post. I will definitely comeback.

  49. Hello this is a wonderful write-up. I’m going to e mail this to my friends. I came on this while searching on yahoo I’ll be sure to come back. thanks for sharing.

  50. That’s some inspirational stuff. Never knew that opinions might be this varied. Thanks for all the enthusiasm to supply such helpful information here.

  51. A good web site with interesting content, that’s what I need. Thank you for making this web site, and I will be visiting again. Do you do newsletters? I Can’t find it.

  52. I’m truly enjoying the design and layout of your blog.It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit moreoften. Did you hire out a developer to create your theme?Fantastic work!

  53. Great blog here! Also your website loads up very fast!
    What web host are you using? Can I get your affiliate link to your host?
    I wish my web site loaded up as quickly as yours lol

  54. I think that is among the most important information for me.
    And i’m satisfied reading your article. But should commentary on some normal things, The site taste is ideal, the articles is in point of fact
    excellent : D. Good process, cheers

  55. Everything is very open with a really clear explanation of the challenges.

    It was truly informative. Your website is extremely helpful.
    Thank you for sharing!

  56. I’m not sure where you are getting your info, but goodtopic. I needs to spend some time learning more or understanding more.Thanks for magnificent info I was looking for this info for my mission.

  57. Hi there! This article could not be written any better! Reading through this post reminds me of my previous roommate! He constantly kept preaching about this. I will forward this post to him. Fairly certain he will have a good read. I appreciate you for sharing!

  58. Heya i’m for the primary time here. I found this board and I find It truly
    helpful & it helped me out much. I am hoping to present one thing again and aid others like you aided me.

  59. Wow! This could be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Actually Magnificent. I am also an expert in this topic so I can understand your effort.

  60. As a Newbie, I am constantly browsing online for articles thatcan be of assistance to me. Thank youAlso visit my blog post … Solessa Anti Aging Serum

  61. Oh my goodness! Awesome article dude! Thank you,
    However I am going through difficulties with your RSS.

    I don’t know the reason why I cannot subscribe to it.

    Is there anybody getting the same RSS problems? Anyone that knows the answer will you kindly respond?
    Thanks!!

  62. What i do not realize is in reality how you’re no longer really a lot more
    smartly-appreciated than you may be right now. You’re so intelligent.
    You realize thus considerably when it comes to this matter, made me in my view believe it from numerous varied angles.

    Its like women and men aren’t fascinated until it is
    one thing to do with Girl gaga! Your own stuffs great. All the time
    deal with it up!

  63. I really love your site.. Very nice colors & theme. Did you create this website yourself? Please reply back as I’m trying to create my own personal site and want to know where you got this from or what the theme is called. Cheers.

  64. Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.

    She never wants to go back! LoL I know this is totally off topic but
    I had to tell someone!

  65. Hi there! I know this is kinda off topic however , I’d figured I’d ask.

    Would you be interested in exchanging links or maybe guest authoring a blog article or vice-versa?
    My site goes over a lot of the same topics as yours and
    I think we could greatly benefit from each other.
    If you might be interested feel free to shoot me an email.

    I look forward to hearing from you! Fantastic blog by
    the way!

  66. Having read this I believed it was rather enlightening.
    I appreciate you spending some time and energy
    to put this short article together. I once again find myself spending way
    too much time both reading and commenting. But so what, it was still worth it!

  67. wonderful publish, very informative. I ponder why the other experts of this sector do not notice this. You should continue your writing. I’m confident, you have a great readers’ base already!

  68. Good site! I truly love how it is easy on my eyes it is. I am wondering how I might be notified when a new post has been made. I’ve subscribed to your RSS which may do the trick? Have a great day!

  69. The very next time I read a blog, Hopefully it doesn’t disappoint me as much as this particular one. After all, Yes, it was my choice to read through, however I truly believed you would probably have something interesting to say. All I hear is a bunch of whining about something you could fix if you weren’t too busy seeking attention.

  70. Hi there I am so glad I found your web site, I really found you by error, while I was looking
    on Yahoo for something else, Regardless I am here now and would just like to say kudos for a tremendous post and a all round enjoyable blog (I also love
    the theme/design), I don’t have time to browse it all at the minute but I
    have book-marked it and also included your RSS feeds, so when I have time I will
    be back to read a lot more, Please do keep up the fantastic work.

  71. Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.

  72. I loved your idea there, I tell you blogs are so exciting sometimes like looking into people’s private life’s and work. Every new remark wonderful in its own right.

  73. Hi there, I found your blog by way of Google even as looking for a
    comparable topic, your web site came up, it appears good.

    I’ve bookmarked it in my google bookmarks.

    Hello there, simply turned into aware of your blog thru Google, and located that it is really informative.

    I’m gonna watch out for brussels. I’ll be grateful in case you proceed this in future.
    A lot of people will be benefited from your writing.
    Cheers!

  74. Attractive section of content. I just stumbled upon your website and in accession capital to assert that I get in fact enjoyed account your blog posts.
    Anyway I’ll be subscribing to your feeds and even I
    achievement you access consistently rapidly.

  75. Thank you, I’ve just been searching for information about this topic for ages and yours is the greatest I’ve discovered so far. But, what about the conclusion? Are you sure about the source?

  76. Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.

  77. Thanks , I have just been searching for info about this subject for a long time and yours is the greatest I have discovered so far. But, what concerning the bottom line? Are you sure about the source?

  78. Aw, this was an incredibly good post. Taking the time and actual effort to produce a very good article… but what can I say… I hesitate a whole lot and don’t seem to get anything done.

  79. Thanks , I’ve recently been searching for info about this topic for ages and yours is the best I have discovered so far. But, what concerning the bottom line? Are you certain concerning the source?

  80. However, it is virtually all done with tongues rooted solidly in cheeks, and everyone has absolutely nothing but absolutely love for his or her friendly neighborhood scapegoat. The truth is, he is not just a pushover. He is basically that special variety of person strong enough to take all of that good natured ribbing for exactly what it is.

  81. Hello there! I could have sworn I’ve visited this site before but after going through many of the posts I realized it’s new to me. Regardless, I’m definitely pleased I stumbled upon it and I’ll be bookmarking it and checking back regularly!

Leave a Comment

Your email address will not be published. Required fields are marked *