-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Create an Ubuntu Linux AWS EC2 instance image in the EC2 management console on aws.amazon.com. Set the security group up so that incoming port 22 is available to all or at least your IP/IP group depending on what is needed. Create a second security rule with the 'type' set as 'HTTP' on port 80 and make it available to any incoming IP in order that the web app will be available publicly (if that is the security level you want).
Name and download the *.pem
key file.
Next, move the *.pem
file to .ssh folder for safe keeping. Navigate to where the file was downloaded to and:
mv *.pem ~/.ssh/
Then secure the *.pem
file by:
sudo chmod 600 *.pem
When that is finished, the EC2 instance can be sshed into. In order to ease this process, it is best to add your ssh key to the authorized_keys
file in the EC2 instance. This is not necessary, but will make working with it more simple. If you have set up ssh keys with GitHub you can find your public key at https://github.com/your_username_here.keys
ssh ~/.ssh/*.pem ubuntu@your_url_here
(url can be found in the AWS EC2 Management Console)
From there you will need to copy your ssh-rsa public key into the file by:
cd ~/.ssh/
nano authorized_keys
Then copy and paste your key, including the 'ssh-rsa' piece to the next line in the file, save and exit nano.
The following is assuming you have added your ssh key to the authorized_keys
file in your instance. If not, you need to add the following immediately after the scp
command -i ~/.ssh/*.pem
Make sure the project is working properly in the Vagrant. When you are ready to put it up, run grunt build
in the www/
directory one more time.
Then, from the www/
directory:
scp -r public/ ubuntu@your_url_here:.
scp -r routes/ ubuntu@your_url_here:.
scp server.js ubuntu@your_url_here:.
scp package.json ubuntu@your_url_here:.
Do not forget the :.
after the url.
When those files have been successful sent up, the bootstrap files need to copied as well. Before doing that make sure to change any references to /vagrant
in the bootstrap files to /var
. This is extremely important. Don't forget to change them back for local development after copying them to the EC2.
Then from the local project root:
scp -r bootstrapping/ ubuntu@your_url_here:.
Now you need to ssh into the EC2 to put the files into their proper locations.
ssh ubuntu@your_url_here
cd ../../var/
mkdir www
cd ~
sudo mv public/ ../../var/www/
sudo mv routes/ ../../var/www/
sudo mv server.js ../../var/www/
sudo mv package.json ../../var/www/
The sudo
is necessary because of var folder permissions
sudo mv bootstrapping/ ../../var/
Navigate to the var/ directory inside the EC2 instance.
cd bootstrapping
sh bootstrap.sh
If all went correctly, the web application should be available and running publicly at its url.
In order to see the live node.js console as the server is running to debug if needed:
sudo tail -f /var/log/nodeserver.sys.log