syxolk / euro2024

Euro 2024: Betting with your friends
https://www.wetten2024.de
54 stars 22 forks source link

Amazon EC2 Linux VM Nodejs tutorial #10

Closed vanshyp closed 8 years ago

vanshyp commented 8 years ago

Follow this tutorial to launch a Linux VM on Amazon EC2: https://aws.amazon.com/getting-started/launch-a-virtual-machine-B-0/

Allow inbound HTTP through AWS Security Groups pane:

HTTP TCP 80 0.0.0.0/0

Log into your instance:

ssh -i ~/.ssh/MyKeyPair.pem ec2-user@{IP_Address} sudo yum update

Nodejs install latest version

sudo -s curl -sL https://rpm.nodesource.com/setup_6.x | bash - yum install -y nodejs exit

Postgres install

sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs

Postgres edit pg_hba.conf to allow local connections:

sudo nano /var/lib/pgsql9/data/pg_hba.conf

File content:

local all all trust host all 127.0.0.1/32 trust

Postgres setup

sudo service postgresql initdb sudo service postgresql start

Postgres login as postgres user

sudo -u postgres psql postgres

Postgres change postgres password

postgres=# \password postgres

Postgres create db and user

postgres=# CREATE DATABASE euro2016; postgres=# CREATE USER blabla password 'blibli'; postgres=# GRANT ALL ON DATABASE euro2016 TO blabla; postgres=# \q

Allow port forwarding:

sudo nano /etc/sysctl.conf net.ipv4.ip_forward 1 sudo sysctl -p /etc/sysctl.conf

Route port 80 to 8080:

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 sudo iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT sudo iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT

Git install

sudo yum install git

App clone

git clone https://github.com/syxolk/euro2016.git

App install

cd euro2016 npm install sudo npm install -g bower

Config file edit

cp template.config.coffee config.coffee nano config.coffee

File content:

URL origin of the web server

origin: 'http://My_IP_Address'

PostreSQL connection URL

db: 'postgres://blabla:blibli@localhost:5432/euro2016'

Password registration captcha

recaptcha: key: 'My_KEY' secret: 'My_SECRET_KEY'

Forever install and launch app

sudo npm install -g forever forever start index.js

If at any point you need to restart the app:

forever restart 0

If you reboot your server instance, don't forget to restart postgres and run iptables rules (or retain these settings the advised way).

You have to register for services listed in the config file and get security codes from these services to fully get up and running. Mailgun requires a domain name. There are several free options.

syxolk commented 8 years ago

Can you make a pull request for this guide? Just put everything in a file INSTALL_AWS.md or similar and reference it in README.md

syxolk commented 8 years ago

Added tutorial to wiki