-
Notifications
You must be signed in to change notification settings - Fork 1
Installation Instructions
bwtaylor edited this page Oct 14, 2014
·
2 revisions
These instructions are for CentOs 7.
yum update
yum groupinstall development
yum install git patch pcre pcre-devel openssl openssl-devel curl curl-devel libxslt-devel libxml2-devel sqlite-devel
Install rvm
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
Install ruby 1.9.3
rvm install 1.9.3
rvm use 1.9.3 --default
Create rails user & add to rvm group
useradd rails
usermod -a -G rvm rails
ssh rails@<host>
ssh-keygen
passwd rails # if desired, or use ssh key
Add you public key ~/.ssh/id_rsa.pub as a deploy key for your github fork of pawn parade
Install Pawn Parade
git clone git@github.com:<GITHUB_USER>/pawn-parade.git
git checkout castle
Install & Start nginx
yum install nginx
systemctl start nginx.service
Configure Firewall
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
Install basic gems
gem install bundler rails
Install MariaDB
yum install mariadb mariadb-devel maridadb-server
systemctl start mariadb.service
mysql_secure_installation
Set Up Rails Env Config
vi ~/.rails_env.sh
Create a file like this:
export RAILS_ENV=production
export DB_USER=rails
export DB_PASSWORD=<PASSWORD>
export DB_HOST=localhost
export RAILS_DB=pawn_parade
export CANONICAL_HOST=castle-chess.org
export EMAIL_DOMAIN=castle-chess.org
export SMTP_ADDRESS=smtp.mailgun.org
export SMTP_USERNAME=postmaster@castle-chess.org
export SMTP_PASSWORD=<PASSWORD>
export PERFORM_DELIVERIES=NO
Add to .bashrc:
appenv=~/.rails_env.sh && test -f $appenv && source $appenv
Create MySQL user
mysql -u root -p
create database <$RAILS_DB>;
Set Up Local Rails User
use mysql;
create user 'rails'@'localhost' identified by '<PASSWORD>';
grant all privileges on pawn_parade.* to 'rails'@'localhost';
mysql -u $DB_USER -p$DB_PASSWORD -h localhost $RAILS_DB; #test
Install Pawn Parade tables
cd pawn-parade
gem install mysql2 -v '0.3.15'
bundle install
rake db:migrate
For non-production environments, launch the app via rails server, to bring it up on http://localhost:3000
rails server
For production environments, use unicorn
gem install unicorn
We'll run nginx as rails
vi /etc/nginx/nginx.conf
Change "user nginx;" to "user rails;"
vi /etc/nginx/conf.d/default.conf
upstream app {
server unix:/tmp/unicorn.pawn-parade.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
server_name castle-chess.org;
root /home/rails/pawn-parade/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
#proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
Now run unicorn:
bundle exec unicorn -E production -c config/unicorn.rb -D
And restart nginx:
systemctl restart nginx.service
This doesn't cover SSL Cert installation.