Skip to content

Instantly share code, notes, and snippets.

@mrkplt
Last active January 2, 2016 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkplt/8340878 to your computer and use it in GitHub Desktop.
Save mrkplt/8340878 to your computer and use it in GitHub Desktop.
Getting postgres, unicorn and nginx running on an e2 instance. There are config files to accompany this. Will link later.
# http://codingsteps.com/installing-and-configuring-postgresql-in-amazon-linux-ami/
sudo su -
gem install unicorn
exit
sudo yum -y install nginx
sudo yum -y install readline-devel
sudo yum -y install zlib-devel
wget http://ftp.postgresql.org/pub/source/v9.2.6/postgresql-9.2.6.tar.bz2
bzip2 -d postgresql-9.2.6.tar.bz2
tar -xf postgresql-9.2.6.tar
cd postgresql-9.2.6
./configure
gmake
sudo gmake install
sudo adduser postgres
sudo passwd postgres
sudo mkdir /usr/local/pgsql/data
sudo mkdir /var/log/pgsql
sudo chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
exit
sudo yum -y install postgresql-devel
# add project to server from local
# scp -i ~/.ssh/tamman_pair.pem -r ~/Code/your_app ec2-user@54.209.176.13:
sudo mkdir /data
sudo mv ~/your_app /data/your_app
sudo ln -s /data/your_app /current
sudo cp /current/config/postgres /etc/init.d/postgres
sudo cp /current/config/nginx /etc/init.d/nginx
sudo cp /current/config/unicorn /etc/init.d/unicorn
sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
sudo cp /current/config/nginx.conf /etc/nginx/nginx.conf
sudo chmod 755 /etc/init.d/postgres
sudo chmod 755 /etc/init.d/nginx
sudo chmod 755 /etc/init.d/unicorn
sudo chkconfig --add unicorn
sudo chkconfig --add postgres
sudo chkconfig --add nginx
sudo chkconfig unicorn on
sudo chkconfig postgres on
sudo chkconfig nginx on
sudo service postgres start
sudo service nginx start
cd /current
bundle install --deployment
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake db:seed
sudo service unicorn start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment