GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add changes :first_quarter_moon_with_face: · gokulcoder7/fullstack-javascript@61ea6d0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • chapter8
    • chapter8.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎chapter8/chapter8.md‎

Copy file name to clipboardExpand all lines: chapter8/chapter8.md
+17-23Lines changed: 17 additions & 23 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -745,20 +745,20 @@ Another header that we send back with the response is `Content-Length`:
745745
746746
So this piece of code goes into the request handler of the server, which is inside of the database connect call. Just like the Russian Matreshka dolls. Confusing? Just refer to the full source code at <http://bit.ly/2LdCK20>.
747747
748-
Another, more elegant way is to use Node.js frameworks as Connect (<http://www.senchalabs.org/connect/static.html>), or Express (<http://expressjs.com>); because there is a special `static` middleware for JS and CSS assets. But those frameworks deserve a book on their own.
748+
Another, more elegant way is to use Node.js frameworks such as Connect or Express; because there is a special `static` middleware for JS and CSS assets. But those frameworks deserve a book on their own.
749749
750-
Now after you mastered basics of Node.js, MongoDB, Backbone.js, and Heroku, there's one bonus step to take. Check out the cloud solution Amazon Web Services known as EC2 (Infrastructure as a Service category of cloud computing).
750+
Now that you've mastered the basics of Node.js, MongoDB, Backbone.js, and Heroku, there's one bonus step to take: deployment to the cloud. Check out the cloud solution Amazon Web Services known as EC2 (Infrastructure as a Service category of cloud computing).
751751
752752
Deployment to Amazon Web Services
753753
============================================================================================================================================
754754
755-
Cloud is eating the world of computing. There are private and public clouds. AWS, probably the most popular choice among the public cloud offerings, falls under the IaaS category. The advantages of using an IaaS such as AWS over PaaS-like Heroku are as follows:
755+
Cloud is eating the world of computing. You can say that cloud has taken the world of IT by storm. There are private and public clouds. AWS, probably the most popular choice among the public cloud options, offers Elastic Compute Cloud (EC2) in the infrastructure as a Service (IaaS) category of cloud solutions. The advantages of using an IaaS such as AWS EC2 over PaaS-like Heroku are as follows:
756756
757757
- It’s more configurable (any services, packages, or operation systems).
758758
- It’s more controllable. There are no restrictions or limitations.
759759
- It’s cheaper to maintain. PaaS can quickly cost a fortune for high-performance resources.
760760
761-
In this tutorial, we'll be using 64-bit Amazon Linux AMI (<http://aws.amazon.com/amazon-linux-ami>) with CentOS (<http://aws.amazon.com/amazon-linux-ami>).
761+
In this tutorial, we'll be using the 64-bit Amazon Linux AMI (<http://aws.amazon.com/amazon-linux-ami>) with CentOS (<http://aws.amazon.com/amazon-linux-ami>).
762762
763763
Assuming you have your EC2 instance up and running, SSH into it and install all system updates with `yum`:
764764
@@ -779,7 +779,7 @@ You probably know this, but just in case, to check installations, type the follo
779779
$ node –V
780780
$ npm –v
781781
782-
If the yum Node.js installation fails, see if you have EPEL (just see if the command below says `epel`):
782+
If the `yum` Node.js installation fails, see if you have EPEL (just see if the command below says `epel`):
783783
784784
$ yum repolist
785785
@@ -791,19 +791,19 @@ Then, try to install both Node.js and npm again with:
791791
792792
$ sudo yum install nodejs npm --enablerepo=epel
793793
794-
Alternatively, you can compile Node.js from the source. To do so, install C++ compiler (again with `yum`):
794+
Alternatively, you can compile Node.js from the source. To do so, install the C++ compiler (again with `yum`):
795795
796796
$ sudo yum install gcc-c++ make
797797
798798
Same with openSSL:
799799
800800
$ sudo yum install openssl-devel
801801
802-
Then install Git with yum:
802+
Then install Git with `yum`:
803803
804804
$ sudo yum install git
805805
806-
Finally, clone Node.js repository straight from GitHub:
806+
Finally, clone the Node.js repository straight from GitHub:
807807
808808
$ git clone git://github.com/joyent/node.git
809809
@@ -815,21 +815,15 @@ And build Node.js:
815815
$ make
816816
$ sudo make install
817817
818-
Note: For a different version of Node.js, you can list them all with `$ git tag -l` and checkout the one you need.
818+
**Note** For a different version of Node.js, you can list all versions with `$ git tag -l` and check out the one you need.
819819
820820
To install npm, run:
821821
822822
$ git clone https://github.com/isaacs/npm.git
823823
$ cd npm
824824
$ sudo make install
825825
826-
More information on using yum can be found at the following locations:
827-
828-
- [Managing Software with yum](https://www.centos.org/docs/5/html/yum) (<https://www.centos.org/docs/5/html/yum>)
829-
- [Installing Node.js via package managers](https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager) (<https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager>)
830-
- [Tips on securing your EC2 instance](http://aws.amazon.com/articles/1233) (<http://aws.amazon.com/articles/1233>)
831-
832-
Once you have Git and npm and Node, you are good to deploy your code (manually). Pull the code from the repository. You might need to provide credentials or upload your SSH keys to the AWS. Then start the Node server with [pm2](https://github.com/Unitech/pm2) (<https://github.com/Unitech/pm2>) or similar process manager (Figure 8-1). `pm2` is good because it has a lot of features not only to keep the process running but also to scale it; it even has load balancing.
826+
Once you have Git and npm and Node.js, you are good to deploy your code (manually). Pull the code from the repository. You might need to provide credentials or upload your SSH keys to AWS. Then start the Node.js server with `pm2` (<https://npmjs.com/pm2> and <https://pm2.io>) or similar process manager. `pm2` is good because it has a lot of features not only to keep the process running but also to scale it as show in Figure 8-1. `pm2` also has load balancing.
833827
834828
To install pm2:
835829
@@ -845,11 +839,11 @@ To list all running processes:
845839
846840
![](media/image1.png)
847841
848-
***Figure 8-1*** *pm2 running multiple Node.js processes.*
842+
***Figure 8-1.*** *pm2 running multiple Node.js processes*
849843
850-
That's pretty much all you need to do. Ideally you want to automate the deployment. Also, you might want to add some `d.init` or `upstart` scripts to launch your `pm2` or another process manager automatically.
844+
That's pretty much all you need to do. Ideally, you want to automate the deployment. Also, you might want to add some `d.init` or `upstart` scripts to launch your `pm2` or another process manager automatically.
851845
852-
Steps for other OS on AWS are similar. You would use their package manager to install Node, Git, and npm, then get the code (Git or rsync) and launch it with the process manager. You don't need the process manager. You can launch with `node` itself, but it's better to use some process manager.
846+
Steps for other OSs on AWS are similar. You would use their package manager to install Node.js, Git, and npm, then get the code (Git or rsync) and launch it with the process manager. You don't need the process manager. You can launch with `node` itself, but it's better to use some process manager.
853847
854848
Now, while the Node.js app is running, executing `$ netstat -apn | grep 80`, the remote machine should show the process. For example, for a Node.js app listening on port 80:
855849
@@ -861,17 +855,17 @@ On the EC2 instance, either configure the firewall to redirect connections (e.g.
861855
862856
$ service iptables save$ service iptables stop$ chkconfig iptables off
863857
864-
In the AWS console, find your EC2 instance and apply a proper rule to allow for inbound traffic, for example,
858+
In the AWS console, find your EC2 instance and apply a proper rule to allow for inbound traffic; for example:
865859
866860
Protocol: TCPPort Range: 80Source: 0.0.0.0/0
867861
868-
And from your local machine, that is, your development computer, you can either use the public IP or the public DNS (the Domain Name System) domain, which is found and copied from the AWS console under that instance’s description. For example,
862+
And from your local machine, that is, your development computer, you can either use the public IP address or the public DNS (the Domain Name System) domain, which is found and copied from the AWS console under that instance’s description. For example,
869863
870864
$ curl XXX.XXX.XXX.XXX –v
871865
872-
It’s worth mentioning that AWS supports many other operating systems via its AWS Marketplace (<https://aws.amazon.com/marketplace>). Although AWS EC2 is a very popular and affordable choice, there other alternatives as well: [Joyent](http://www.joyent.com) (<https://www.joyent.com>), [Microsoft Azure](https://azure.microsoft.com/en-us) (https://azure.microsoft.com/en-us), [Rackspace Open Cloud](http://www.rackspace.com/cloud) (<http://www.rackspace.com/cloud>), and others.
866+
It’s worth mentioning that AWS supports many other operating systems via its AWS Marketplace (<https://aws.amazon.com/marketplace>). Although AWS EC2 is a very popular and affordable choice, there are other alternatives as well: Google Cloud (<https://cloud.google.com>), Microsoft Azure (<https://azure.microsoft.com>), IBM Cloud (<https://www.ibm.com/cloud>), and others.
873867
874868
Summary
875869
=======
876870
877-
This chapter deals with descriptions of different deployment approaches, the final version of Message Board application, and its deployment with two approaches: different and the same domains. We covered deployment using the Git and Heroku command-line interfaces to deploy to PaaS. And we worked through examples of installing and building a Node.js environment on AWS EC2 and running Node.js apps on AWS with CentOS.
871+
This chapter presented the descriptions of different deployment approaches, the final version of the Message Board application, and its deployment with two approaches: on different domains and on the same domains. We covered deployment using the Git and Heroku command-line interfaces to deploy to PaaS. And we worked through examples of installing and building a Node.js environment on AWS EC2 and running Node.js apps on AWS with CentOS.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.