Step By Step Guide to your own testing server with nodejs
Create an Amazon Web Services (AWS) account
Your first step is to create an Amazon Web Services (AWS) account (if you already have an Amazon.com account for shopping, you can use that).
Launch an EC2 instance (web server)
Next, In order to install and run Node, you need a server, also known as an instance. Each running web server in the EC2 service is called an instance because you can have many of them running in parallel. For now, you only need one.
Login with your AWS account and go to the EC2 tab in the AWS Management Console. Before launching your instance, Amazon gives you the option to choose a location. The cost varies between locations (although it’s free for the first year). There will most likely be a location labeled as eligible for free service, that will be the one you choose. You can check the most up to date current prices on Amazon.
After choosing a location, click the “Review & Launch” button. Give a name to your instance if you like, then type any name for the key pair file and download it (this is extremely important, so keep that file secure). Then choose an AMI (Amazon Machine Image). Choose the 64 bit Amazon Linux OS for the best security and performance in the cloud.
It's important to note that there are many automated setup tools available to you, but it's important you learn how to administer and maintain it manually, so you get an idea of what's happening behind the scenes. Finally, in the next screen just hit Launch.
Your instance is now launching and may take a few minutes. Click the View your instances on the Instances page link in the last page in the popup and you will be redirected to your instance's information screen. You can now use your instance’s public dns to connect to your server via ssh.
Amazon does not provide a custom username and password for ssh connections. Instead, they use the key pair file you created a couple of steps ago (a more secure practice). Before you can use the .pem file you downloaded, you must first set it to be accessible only by it's owner and read access only. To do that, run
chmod 400 /path/to/cert.pem.
Connect to Amazon EC2 using
ssh -i /path/to/my-key-pair.pem [email protected] where
ec2-198-51-100-1.compute-1.amazonaws.com is your public ec2 url. You are now logged-in into your instance! I recommend creating an alias for the above command to make your life easier. If you're using bash you can run
echo "alias ec2='ssh -i /path/to/my-key-pair.pem [email protected]'" >> ~/.bashrc && . ~/.bashrc
This will create the ec2 alias in your .bashrc and set it to be usable right away. Any time you need to connect to EC2, you can now just run
Update your EC2 Amazon Linux
On your first login, there will be updates to install on your new instance. To install them, run:
sudo yum -y update. Wait a few minutes for the updates to install, then we're ready to install Node!