Skip to content

System Setup on Fedora (CentOS 6.4)

benrudolph edited this page Oct 9, 2014 · 29 revisions

Contents

Configuration Setup

  • Creating a deploy user
  • Proxy setup
  • Deploy setup
  • Auto SSH login

Installation Requirements

  • Ruby
  • Nginx-Passenger
  • Ruby-on-rails
  • sqlite3
  • elasticsearch
  • whenever gem
  • phantomjs
  • redis
  • postgresql

Configuration Setup

Creating a deploy user

Create username and password

useradd deploy
passwd <password>

Add the deploy user to the list of sudoers by typing visudo and pasting this line:

deploy ALL=(ALL) ALL

To ensure that paths stay the same when running in sudo, change secure_path in visudo to:

Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/home/deploy/.rbenv/shims

Comment out Default requiretty in order to run sprinkle without sudo problems.

Proxy Setup

Add these two lines to your .bashrc to set proxy environment variables

export https_proxy=https://proxy.unhcr.local:8080
export http_proxy=http://proxy.unhcr.local:8080

Deploy Setup

Create /var/www/ folder and have deploy user own it.

mkdir /var/www/
chown deploy /var/www

Auto SSH login

On your local computer run:

ssh-keygen -t rsa

Create .ssh folder on your remote server

ssh deploy@<remote_server> mkdir -p .ssh
chmod 700 .ssh

Now again from your local computer:

cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys2 && chmod 640 .ssh/authorized_keys2'

Installation Requirements

Ruby

As a ruby environment manager we'll using rbenv. The installation instructions are found on that page. Attempt to use ruby-build to install 2.0.0-p353. As of now there is a bug that is noted here.

If the proposed fix didn't work follow the next steps (Skip this part if ruby successfully installed).

cd ~/.rbenv/versions/

Now download ruby version 2.0.0-p353.

wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz

Unzip the tar and install. Once you've installed ruby, you'll want to add the gem binary to your path. Insert this into your .bashrc:

export PATH=$PATH:$HOME/.rbenv/bin

tar -zxvf ruby-2.0.0-p353.tar.gz
cd ruby-2.0.0-p353
./configure
make
sudo make install
rm ruby-2.0.0-p353.tar.gz

Nginx-passenger

Next we need to setup Nginx passenger. For this use the guide here. Complete steps 1 and 2 only.

Sqlite3

yum install sqlite3-devel

ElasticSearch

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.11.noarch.rpm`
rpm -i elasticsearch-0.90.11.noarch.rpm

Whenever gem

This sets up cron jobs for the weekly build. https://github.com/javan/whenever

gem install whenever

phantomjs

cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
tar xvjf phantomjs-1.9.7-linux-x86_64.tar.bz2
sudo cp phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin

redis

cd ~
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
sudo cp src/redis-benchmark /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/
sudo cp src/redis-server /usr/local/bin/
sudo cp redis.conf /etc/
sudo sed -i 's/daemonize no/daemonize yes/' /etc/redis.conf
sudo sed -i 's/^pidfile \/var\/run\/redis.pid/pidfile \/tmp\/redis.pid/' /etc/redis.conf

postgresql

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-a-centos-vps

Will have to modify pg_hba.conf file: http://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge

Note to modify Postgres password at the start you'll have to set the config to "trust" first

When installing the gem, it may error because it cannot find the pg_config file. Ensure that you simlink the pg_config to /usr/local/bin:

sudo ln -s /usr/pgsql-9.3/bin/pg_config /usr/local/bin

NLTK for summarizer

Install pip:

http://pip.readthedocs.org/en/latest/installing.html

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py --proxy="http://proxy.unhcr.local:8080"

Install dependencies:

sudo yum install python-devel
sudo pip install networkx --proxy="http://proxy.unhcr.local:8080"
sudo yum install python-psycopg2
sudo pip install pyyaml --proxy="http://proxy.unhcr.local:8080"

Install nltk:

sudo pip install nltk --proxy="http://proxy.unhcr.local:8080"

Download nltk pkgs:

python
>>> import nltk
>>> nltk.download()
Downloader> d punkt
Downloader> d stopwords

Note: Ensure there is host specified in the database.yml in order for the script to connect to the database. It should be localhost.

Ensure Summarizer is working:

sudo pip install pytest --proxy="http://proxy.unhcr.local:8080"
cd /var/www/visio/current && py.test -v script/python/summarizer/summarize_test.py