Go into aws and set up an account. It's free with the basic account but credit card and phone verification is still required. Takes a few minutes.
Go to "My Account" > "AWS Management Console". Then "Launch Instance":
- Choose 64-bit Ubuntu Server with the free tier instance.
- Launch Instance (don't worry about security for now).
- A prompt to add key pair will show up. Create and download a new one. (don't lose it)
- Launch again!
Under Network Security, click on Security Groups. Select the group created for the instance. At the bottom, there are tabs with options, click on Inbound. This is were rules can be added to only allow certain IPs and connections to the server. For now, edit and add a new rule to allow all TCP from anywhere.
Under "Instances", click on instances and find the public IP for the instance that we created. We'll use it in a bit.
Copy the SSH key (that was downloaded and not lost) and paste it into the /.ssh file. Then change ownership to secure it:
chmod 600 /.ssh [ssh_key].pem
Now, connect to the instance: ssh -i ~/.ssh/[ssh_key].pem ubuntu@[ip address]
Go to a domain site and purchase a name. They range around $10. Here are some places to start:
Then, navigate to editing the DNS records for that domain. Add a basic type A host with the IP of the AWS server previously set up and the name of the domain.
Extra: add a type CNAME host with the same IP address and the name of www to catch and redirect anyone trying to go to www.yourdomain
- Connect back to the AWS Server:
ssh -i ~/.ssh/[ssh_key].pem ubuntu@[ip address]
- Add a new user through the following commands
- sudo adduser [your name]
- sudo gpasswd -a [your name] sudo
- Remove root user
- vi /etc/ssh/sshd_config
- find PermitRootLogin yes, and change to no
- service ssh restart
- su [your name]
Use sudo apt-get install
to install most technologies into the server. To get started, type sudo apt-get update
.
Nginx and Passenger:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
sudo apt-get install apt-transport-https ca-certificates
sudo touch /etc/apt/sources.list.d/passenger.list
sudo vi /etc/apt/sources.list.d/passenger.list
- include this inside:
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
- include this inside:
sudo chown root: /etc/apt/sources.list.d/passenger.list
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
sudo apt-get update
sudo apt-get install nginx-extras passenger
sudo vi /etc/nginx/nginx.conf
- uncomment
passenger_root
andpassenger_ruby
by removing#
- uncomment
sudo service nginx restart
EXTRA
Git:
sudo apt-get install git
Node:
- Node Instructions or
sudo apt-get install nodejs
sudo apt-get install npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
Create a file and tell Nginx where we keep the files we want it to serve up to browsers
sudo mkdir /usr/share/nginx/www
cd /usr/share/nginx/www
sudo chown -R [your name] .
sudo chgrp -R www-data .
sudo chmod -R 750 .
sudo chmod g+s .
Inside nginx's www file, add your project (git is the easiest way). Then, add it as an enabled site:
sudo vi /etc/nginx/sites-enabled/default
- change
root /usr/share/nginx/html;
toroot /usr/share/nginx/www;
to point to the correct folder - change
server_name _;
toserver_name [yourdomain];
- change
Lastly, install the dependencies for the project. They are unique to each case, here are some examples:
sudo apt-get update
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
to loadrvm requirements
to install dependencies of rvmrvm use ruby --latest
and thenrvm install [whatever lastest version]
gem install rails
sudo apt-get install bundler
sudo apt-get install postgresql-9.3
sudo apt-get install libpq-dev
- use
sudo su - postgres
to gain access
That's it!