Deploying Rails Apps using Capistrano (Bonus)

Table of Contents

 

MySQL

To instal MySQL Server and Client, run the following command and follow the steps provided by the installation wizard.

sudo aptitude install mysql-server mysql-client libmysqlclient-dev

In order to be able to connect to the MySQL Server instance using a 3rd party client, you’ll have to tunnel your way through SSH, if your setup is similar to the server setup we’ve been working on throughout these tutorials, since connections to the port MySQL Server uses by default are not allowed by the firewall, for security reasons. I use Sequel Pro on my Mac.

The package installation creates a default user root, that I prefer not to use with my deployed Rails applications. I create a new user called deployer, that has privileges to the database that my application uses only. To do so, run the following command.

CREATE USER 'deployer'@'localhost';
GRANT USAGE ON *.* TO 'deployer'@'localhost';

The run the following command to give the user the appropriate privileges. Make sure to change the database name to match the name of your application’s database.

GRANT EXECUTE, SELECT, SHOW VIEW, ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, INDEX, INSERT, REFERENCES, TRIGGER, UPDATE, LOCK TABLES ON `vps_production`.* TO 'deployer'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

 

PostgreSQL

 

MongoDB

 

Redis

To install Redis, first make sure the tcl package is installed.

sudo aptitude install build-essential tcl8.5

Check for the latest version of Redis and grab it into your /tmp directory.

cd /tmp
wget http://download.redis.io/releases/redis-2.8.9.tar.gz

Now extract it.

tar -zxvf redis-2.8.9.tar.gz

Then configure it and install it.

# install the server
cd redis-2.8.9
make
make test
sudo make install

# configure an instance and add it to your boot sequence
cd utils
sudo ./install_server.sh

 

ElasticSearch

Grab the latest .deb package from here.

cd /tmp
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb

Then run the following command to install it.

sudo dpkg -i elasticsearch-1.1.1.deb

ElasticSearch’s wrapper requires Java to run. Make sure to install a Java Runtime Environment (JRE) before running ElasticSearch, using the following command.

sudo aptitude install default-jre

Check out ElasticSearch-Head for a way to view the data in ElasticSearch’s index.

Ramy Aboul Naga (@RaMin0)

A senior web apps developer with 6+ years of experience, who seeks to enrich the aspects of the web, to make it a more friendly environment for those who experience its advantages and nourishing knowledgebase.

3 thoughts to “Deploying Rails Apps using Capistrano (Bonus)”

Leave a Reply

Your email address will not be published. Required fields are marked *