Search

Todd Rodzen

Agile Application Development

Tag

nvm

AMI Build All-in-One

Full build process

  1. Create an EC2 Linux Instance base – Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type – ami-0b33d91d
  2. Install the LAMP Stack default Apache port set to 8080 as it will be served to an Nginx reverse proxy server on the same instance (Apache 2.4, MySQL, PHP 6.7)
  3. Install the MEAN Stack
  4. Install Nginx Reverse Proxy Server
  5. Install ColdFusion 2016 update 3 Server

The server is setup and available for Free with a service contract from GTK Solutions.

Advertisements

Node.js Server on Linux EC2

The following steps are used to install a node.js backend server on a Linux EC2 Instance.

NOTE: with AWS EC2 Linux I prefer to do the install with root so first do a SUDO -i to get to root use mode. Then after the install is done you can copy the changes in the .profilerc from the root user to the ec2-user to make nvm and node commands available to both environments.

  1. Install the Node Version Manager (nvm) from https://github.com/creationix/nvm.
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
  2. To download, compile, and install the latest release of node, do this:
    nvm install node

    Then in any new shell just use the installed version:

    nvm use node
  3. Now go to Sublime text editor and create an hello.js file with:
    // hello.js
    console.log('hello world from Node.js')
  4. Upload the Hello World server node.js to a directory on the server. I created a directory called /node
  5. Now you can run your node.js Hello World test
    [ec2-user@ip-172-31-24-194 node.js]$ cd /node
    [ec2-user@ip-172-31-24-194 node.js]$ node hello.js
    hello world from Node.js
  6. Finally, you should update npm (Node Package Manager) that comes with node to the latest version. Node Package Manager works with packages available at http://npmjs.com. More on the NPM in a later post.
    npm install npm@latest -g
    # FYI - use the next comand to check the current verion of npm
    npm -v

That’s All ! node.js server is setup.

You can use the which node command to find your current node.js version

[ec2-user@ip-172-31-59-183 node.js]$ which node
~/.nvm/versions/node/v7.4.0/bin/node

I also install the latest nightly build of node with the following command. You will then have the latest LTS version plus the nightly build and can switch between them with the NVM USE command.

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly nvm install 8

In a later post we will setup a MySQL to node database connector.

Powered by WordPress.com.

Up ↑