Skip to content

Installing Tracks 2.2.2 on CentOS 6.5 Minimal x86_64

rharmonson edited this page Jul 4, 2014 · 4 revisions

#Installing Tracks 2.2.2 on CentOS 6.5 Minimal x86_64

The purpose of this document is to describe the installation process for Tracks 2.2.2 on CentOS 6.5 Minimal x86_64 using epel repository, rvm, mysql, apache, and phusion passenger. This is but one method of installing Tracks, and I am open to suggestions and constructive criticism.

Build Overview

  1. Base operating system
  2. Prerequisite packages
  3. User account & sudo
  4. MySQL database
  5. Ruby Version Manager (rvm)
  6. Ruby 1.9
  7. Bundler
  8. Phusion Passenger
  9. Tracks 2.2.2
  10. Apache2
  11. Done(?)
  12. Other Considerations

1. Base operating system

See my article at the github wiki repository below:

CentOS 6.5 Minimal x86_64 Base Installation Guide

##2. Prerequisite packages

Including RVM prerequisites, mysql server, apache, and system-config packages for ease of administration.

Reference: https://rvm.io/rvm/prerequisites <-- their list is incomplete!

Note: sqlite-devel package is required for Tracks and bundler.

Note: libxml2-devel, libxslt, and libxslt-devel packagea is required for Tracks, specifically, nokogiri.

Note: httpd-devel and libcurl-devel and dependencies packages are required for passenger.

# yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel sqlite-devel libxml2-devel libxslt libxslt-devel mysql-server mysql-devel httpd httpd-devel libcurl-devel nodejs git subversion system-config-network-tui system-config-firewall-tui

Results with:

================================================================================
 Package                    Arch   Version                        Repository
																		   Size
================================================================================
Installing:
 autoconf                   noarch 2.63-5.1.el6                   base    781 k
 automake                   noarch 1.11.1-4.el6                   base    550 k
 bison                      x86_64 2.4.1-5.el6                    base    637 k
 gcc-c++                    x86_64 4.4.7-4.el6                    base    4.7 M
 git                        x86_64 1.7.1-3.el6_4.1                base    4.6 M
 httpd                      x86_64 2.2.15-30.el6.centos           updates 821 k
 httpd-devel                x86_64 2.2.15-30.el6.centos           updates 150 k
 libcurl-devel              x86_64 7.19.7-37.el6_5.3              updates 244 k
 libffi-devel               x86_64 3.0.5-3.2.el6                  base     18 k
 libtool                    x86_64 2.2.6-15.5.el6                 base    564 k
 libxml2-devel              x86_64 2.7.6-14.el6_5.1               updates 1.1 M
 libxslt                    x86_64 1.1.26-2.el6_3.1               base    452 k
 libxslt-devel              x86_64 1.1.26-2.el6_3.1               base    561 k
 libyaml-devel              x86_64 0.1.6-1.el6                    epel     91 k
 mysql-devel                x86_64 5.1.73-3.el6_5                 updates 129 k
 mysql-server               x86_64 5.1.73-3.el6_5                 updates 8.6 M
 nodejs                     x86_64 0.10.28-1.el6                  epel    497 k
 openssl-devel              x86_64 1.0.1e-16.el6_5.7              updates 1.2 M
 patch                      x86_64 2.6-6.el6                      base     90 k
 readline-devel             x86_64 6.0-4.el6                      base    134 k
 sqlite-devel               x86_64 3.6.20-1.el6                   base     81 k
 subversion                 x86_64 1.6.11-10.el6_5                updates 2.3 M
 system-config-firewall-tui noarch 1.2.27-5.el6                   base     37 k
 system-config-network-tui  noarch 1.6.0.el6.2-1.el6              base    1.2 M
 zlib-devel                 x86_64 1.2.3-29.el6                   base     44 k
Installing for dependencies:
 apr                        x86_64 1.3.9-5.el6_2                  base    123 k
 apr-devel                  x86_64 1.3.9-5.el6_2                  base    176 k
 apr-util                   x86_64 1.3.9-3.el6_0.1                base     87 k
 apr-util-devel             x86_64 1.3.9-3.el6_0.1                base     69 k
 apr-util-ldap              x86_64 1.3.9-3.el6_0.1                base     15 k
 c-ares19                   x86_64 1.9.1-5.el6.3                  epel     73 k
 cloog-ppl                  x86_64 0.15.7-1.2.el6                 base     93 k
 cpp                        x86_64 4.4.7-4.el6                    base    3.7 M
 crda                       x86_64 1.1.1_2010.11.22-1.el6         base     23 k
 cyrus-sasl-devel           x86_64 2.1.23-13.el6_3.1              base    302 k
 db4-cxx                    x86_64 4.7.25-18.el6_4                base    588 k
 db4-devel                  x86_64 4.7.25-18.el6_4                base    6.6 M
 dbus-python                x86_64 0.83.0-6.1.el6                 base    204 k
 expat-devel                x86_64 2.0.1-11.el6_2                 base    120 k
 gcc                        x86_64 4.4.7-4.el6                    base     10 M
 glibc-devel                x86_64 2.12-1.132.el6_5.2             updates 978 k
 glibc-headers              x86_64 2.12-1.132.el6_5.2             updates 608 k
 gnutls                     x86_64 2.8.5-14.el6_5                 updates 346 k
 http-parser                x86_64 2.0-4.20121128gitcd01361.el6   epel     22 k
 httpd-tools                x86_64 2.2.15-30.el6.centos           updates  73 k
 iw                         x86_64 3.10-1.1.el6                   base     55 k
 kernel-headers             x86_64 2.6.32-431.17.1.el6            updates 2.9 M
 keyutils-libs-devel        x86_64 1.4-4.el6                      base     28 k
 krb5-devel                 x86_64 1.10.3-15.el6_5.1              updates 495 k
 libcom_err-devel           x86_64 1.41.12-18.el6                 base     32 k
 libgcrypt-devel            x86_64 1.4.5-11.el6_4                 base    118 k
 libgomp                    x86_64 4.4.7-4.el6                    base    118 k
 libgpg-error-devel         x86_64 1.7-4.el6                      base     14 k
 libidn-devel               x86_64 1.18-2.el6                     base    137 k
 libnl                      x86_64 1.1.4-2.el6                    base    121 k
 libproxy                   x86_64 0.3.0-4.el6_3                  base     39 k
 libproxy-bin               x86_64 0.3.0-4.el6_3                  base    8.2 k
 libproxy-python            x86_64 0.3.0-4.el6_3                  base    8.4 k
 libselinux-devel           x86_64 2.0.94-5.3.el6_4.1             base    136 k
 libsepol-devel             x86_64 2.0.41-4.el6                   base     64 k
 libstdc++-devel            x86_64 4.4.7-4.el6                    base    1.6 M
 libuv                      x86_64 1:0.10.27-1.el6                epel     55 k
 libyaml                    x86_64 0.1.6-1.el6                    epel     52 k
 mailcap                    noarch 2.1.31-2.el6                   base     27 k
 mpfr                       x86_64 2.4.1-6.el6                    base    157 k
 mysql                      x86_64 5.1.73-3.el6_5                 updates 894 k
 ncurses-devel              x86_64 5.7-3.20090208.el6             base    642 k
 neon                       x86_64 0.29.3-3.el6_4                 base    119 k
 openldap-devel             x86_64 2.4.23-34.el6_5.1              updates 1.1 M
 pakchois                   x86_64 0.4-3.2.el6                    base     21 k
 pciutils                   x86_64 3.1.10-2.el6                   base     85 k
 perl                       x86_64 4:5.10.1-136.el6               base     10 M
 perl-DBD-MySQL             x86_64 4.013-3.el6                    base    134 k
 perl-DBI                   x86_64 1.609-4.el6                    base    705 k
 perl-Error                 noarch 1:0.17015-4.el6                base     29 k
 perl-Git                   noarch 1.7.1-3.el6_4.1                base     28 k
 perl-Module-Pluggable      x86_64 1:3.90-136.el6                 base     40 k
 perl-Pod-Escapes           x86_64 1:1.04-136.el6                 base     32 k
 perl-Pod-Simple            x86_64 1:3.13-136.el6                 base    212 k
 perl-URI                   noarch 1.40-2.el6                     base    117 k
 perl-libs                  x86_64 4:5.10.1-136.el6               base    578 k
 perl-version               x86_64 3:0.77-136.el6                 base     51 k
 ppl                        x86_64 0.10.2-11.el6                  base    1.3 M
 python-ethtool             x86_64 0.6-5.el6                      base     31 k
 python-iwlib               x86_64 0.1-1.2.el6                    base     14 k
 rsync                      x86_64 3.0.6-9.el6_4.1                base    334 k
 usermode                   x86_64 1.102-3.el6                    base    187 k
 v8                         x86_64 1:3.14.5.10-8.el6              epel    3.0 M
 wireless-tools             x86_64 1:29-5.1.1.el6                 base     94 k

Transaction Summary
================================================================================
Install      89 Package(s)

Total download size: 79 M
Installed size: 240 M
Is this ok [y/N]:

##3. User account & sudo You may use root or an user account to install Tracks. In practice, using a dedicated user could decrease the risk of root exploits, however, this assumes you do not granting sudo with wide open privileges (command access) to the user. I am over simplifying, so do some googling and decide for yourself. I will be using a user account named tracks with the intent of removing sudo access after testing is complete.

Create user 'tracks'

# useradd tracks --password <password>

Configure tracks user to use 'sudo';

# visudo

Add the following which essentially gives user tracks root equivalent privileges when using sudo.

tracks  ALL=(ALL)       ALL

Log off then on using user tracks to validate functionality before moving to next step. Also, please note the convention I am using is to indicate root with '#' and '$' to represent tracks with sudo when appropriate.

Disable root SSH access.

$ sudo vi /etc/ssh/sshd_config

change

#PermitRootLogin yes

to

PermitRootLogin No

For the changes to take effect immediately, restart sshd.

$ sudo  service sshd restart

##4. MySQL database

Start mysqld.

$ sudo service mysqld start

Configure the basics. Essentially, respond yes to each query.

$ sudo mysql_secure_installation

Enable automatic startup and shutdown; init script.

$ sudo chkconfig mysqld on

Create a new database, user, and grant privileges. Replace dbuser and password with your values.

$ mysql -u root -p

> create database tracks;
> create user 'dbuser'@'localhost' identified by '<password>';
> grant all on tracks.* to 'dbuser'@'localhost' with grant option;
> exit;

##5. Ruby Version Manager (rvm) Validate RVM prerequisite binaries are installed by executing the following as root or with sudo--instructions in section titled Prerequisite packages should have installed the dependencies.

$ sudo for name in {bash,awk,sed,grep,ls,cp,tar,curl,gunzip,bunzip2,git,svn} ; do which $name ;  done

Install Ruby Version Manager (RVM)

$ \curl -sSL https://get.rvm.io | bash -s stable
$ echo source ~/.profile >> .bash_profile

Also, create a .gemrc and configure to not install ri and rdocs by default.

$ echo gem: --no-ri --no-rdoc >> ~/.gemrc

Log off then on or $ source ~/.profile before continuing.

##6. Ruby 1.9 Tracks installation.textile states Tracks version 2.2.2 works best with Ruby 1.9. Verify RVM's requirements have been met then install ruby 1.9.

$ rvm requirements
$ rvm install 1.9

Results with:

Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/x86_64/ruby-1.9.3-p547.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /home/tracks/.rvm/rubies/ruby-1.9.3-p547, this may take a while depending on your cpu(s)...
ruby-1.9.3-p547 - #downloading ruby-1.9.3-p547, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
								 Dload  Upload   Total   Spent    Left  Speed
100 9801k  100 9801k    0     0  1362k      0  0:00:07  0:00:07 --:--:-- 1505k
ruby-1.9.3-p547 - #extracting ruby-1.9.3-p547 to /home/tracks/.rvm/src/ruby-1.9.3-p547...
ruby-1.9.3-p547 - #applying patch /home/tracks/.rvm/patches/ruby/GH-488.patch.ch.
ruby-1.9.3-p547 - #applying patch /home/tracks/.rvm/patches/ruby/ssl_no_ec2m.pat                                         
ruby-1.9.3-p547 - #configuring.....ruby-1.9.3-p547........................................
ruby-1.9.3-p547 - #post-configuration.
ruby-1.9.3-p547 - #compiling...................................................................
ruby-1.9.3-p547 - #installing........................
ruby-1.9.3-p547 - #making binaries executable..
ruby-1.9.3-p547 - #downloading rubygems-2.2.2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
								 Dload  Upload   Total   Spent    Left  Speed
100  404k  100  404k    0     0   919k      0 --:--:-- --:--:-- --:--:-- 1123k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-1.9.3-p547 - #extracting rubygems-2.2.2...
ruby-1.9.3-p547 - #removing old rubygems.........
ruby-1.9.3-p547 - #installing rubygems-2.2.2...............
ruby-1.9.3-p547 - #gemset created /home/tracks/.rvm/gems/ruby-1.9.3-p547@global
ruby-1.9.3-p547 - #importing gemset /home/tracks/.rvm/gemsets/global.gems.............................................................
ruby-1.9.3-p547 - #generating global wrappers.........
ruby-1.9.3-p547 - #gemset created /home/tracks/.rvm/gems/ruby-1.9.3-p547
ruby-1.9.3-p547 - #importing gemsetfile /home/tracks/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-1.9.3-p547 - #generating default wrappers.........
ruby-1.9.3-p547 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-1.9.3-p547 - #complete
WARNING: Please be aware that you just installed a ruby that is no longer maintained (2014-02-23), for a list of maintained rubies visit:

	http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering

Please consider upgrading to ruby-2.1.2 which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri

You must specify a default ruby version, otherwise, executing commands like bundle, below, will fail with an error stating something like 'no such command.'

$ rvm --default use 1.9.3
$ rvm list

##7. Bundler Bundler simplifies meeting Tracks' requirements.

$ gem install bundler
	Fetching: bundler-1.6.2.gem (100%)
	Successfully installed bundler-1.6.2
	1 gem installed
$ bundle -v
Bundler version 1.6.2

##8. Phusion Passenger We are using Apache2 as the web server. Phusion Passenger provides painless integration between Apache2 and Tracks. Also, note rake is installed and a requirement to install Tracks.

$ gem install passenger
	Fetching: daemon_controller-1.2.0.gem (100%)
	Successfully installed daemon_controller-1.2.0
	Fetching: rack-1.5.2.gem (100%)
	Successfully installed rack-1.5.2
	Fetching: passenger-4.0.44.gem (100%)
	Building native extensions.  This could take a while...
	Successfully installed passenger-4.0.44
	3 gems installed
$ passenger -v
Phusion Passenger version 4.0.44

##9. Tracks 2.2.2

Important! At the time of writing this build, the build of Tracks 2.2.2 or 2.3 development failed. Not surprisingly, github build status was failed. As of June 26, 2014, 2.2.2 github build status read success for 2.2.2. Nonetheless, I am using and would advise, initially, using the 2.2.2 tarball, rev gbc8b817, using the "Get Tracks" link from http://getontracks.org/.

###Unpack

$ tar -xzvf tracks-2.2.2.tar.gz
$ mv tracks-2.2.2 ~/tracks

Review ~/tracks/doc/installation.textile for instructions.

###Gems Install gems using bundler

$ cd ~/tracks/
$ bundle install --without development test
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 10.0.3
Installing RedCloth 4.2.9
Installing aasm 3.0.16
Installing i18n 0.6.1
Installing multi_json 1.7.0
Installing activesupport 3.2.13
Installing builder 3.0.4
Installing activemodel 3.2.13
Installing erubis 2.7.0
Installing journey 1.0.4
Installing rack 1.4.5
Installing rack-cache 1.2
Installing rack-test 0.6.2
Installing hike 1.2.1
Installing tilt 1.3.6
Installing sprockets 2.2.2
Installing actionpack 3.2.13
Installing mime-types 1.21
Installing polyglot 0.3.3
Installing treetop 1.4.12
Installing mail 2.5.3
Installing actionmailer 3.2.13
Installing arel 3.0.2
Installing tzinfo 0.3.37
Installing activerecord 3.2.13
Installing activeresource 3.2.13
Installing acts_as_list 0.1.9
Installing bcrypt-ruby 3.0.1
Installing bluecloth 2.2.0
Using bundler 1.6.2
Using cache_digests 0.1.0 from source at vendor/gems/cache_digests-0.1.0
Installing coffee-script-source 1.4.0
Installing execjs 1.4.0
Installing coffee-script 2.2.0
Installing rack-ssl 1.3.3
Installing json 1.7.7
Installing rdoc 3.12.2
Installing thor 0.17.0
Installing railties 3.2.13
Installing coffee-rails 3.2.2
Installing formatize 1.1.0
Installing htmlentities 4.3.1
Installing jquery-rails 2.2.1
Installing libv8 3.11.8.17
Installing mysql2 0.3.11
Installing nokogiri 1.5.6
Installing rack-mini-profiler 0.1.23
Installing rails 3.2.13
Installing rails_autolink 1.0.9
Installing ref 1.0.4
Installing sanitize 2.0.3
Installing sass 3.2.5
Installing sass-rails 3.2.6
Installing sqlite3 1.3.7
Installing swf_fu 2.0.3
Installing therubyracer 0.11.4
Installing uglifier 1.3.0
Installing will_paginate 3.0.4
Your bundle is complete!
Gems in the groups development and test were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!

###Configuration Copy configuration files.

$ cd ~/tracks/config/
$ cp database.yml.tmpl database.yml
$ cp site.yml.tmpl site.yml

Update 'production' stanza account from root to dbuser and provide password.

$ vi database.yml

Update time zone, salt, secret_token, and email address.

$ vi site.yml

Note: we will be using Apache, but initially, let's use WEBrick for an initial testing.

$ vi environments/production.rb

Update config.serve_static_assets to true.

###Schema Create database schema.

$ cd ~/tracks
$ bundle exec rake db:migrate RAILS_ENV=production
==  CreateTracksDb: migrating =================================================
-- create_table(:contexts)
   -> 0.0257s
-- create_table(:projects)
   -> 0.1128s
-- create_table(:todos)
   -> 0.0044s
-- create_table(:users)
   -> 0.0033s
==  CreateTracksDb: migrated (0.1465s) ========================================

==  AddUserId: migrating ======================================================
-- add_column(:contexts, :user_id, :integer, {:default=>1})
   -> 0.0090s

... so much more ...

==  CreateTolkTables: migrating ===============================================
-- create_table(:tolk_locales)
   -> 0.0030s
-- add_index(:tolk_locales, :name, {:unique=>true})
   -> 0.0077s
-- create_table(:tolk_phrases)
   -> 0.0250s
-- create_table(:tolk_translations)
   -> 0.0049s
-- add_index(:tolk_translations, [:phrase_id, :locale_id], {:unique=>true})
   -> 0.0079s
==  CreateTolkTables: migrated (0.0488s) ======================================

==  NoDefaultAdminEmail: migrating ============================================
-- remove_column(:preferences, :admin_email)
   -> 0.0194s
==  NoDefaultAdminEmail: migrated (0.0195s) ===================================

###Precompile Assets

$ cd ~/tracks
$ bundle exec rake assets:precompile
/home/tracks/.rvm/rubies/ruby-1.9.3-p547/bin/ruby /home/tracks/.rvm/gems/ruby-1.9.3-p547/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

###WEBrick Open firewall for Tracks using WEBrick on port 3000 TCP.

$ sudo system-config-firewall-tui

To review iptables policies, execute the following:

$ sudo service iptables status

###Start the Server (test)

$ cd ~/tracks
$ bundle exec rails server -e production
=> Booting WEBrick
=> Rails 3.2.13 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2014-05-31 14:19:21] INFO  WEBrick 1.3.1
[2014-05-31 14:19:21] INFO  ruby 1.9.3 (2014-05-14) [x86_64-linux]
[2014-05-31 14:19:21] INFO  WEBrick::HTTPServer#start: pid=3521 port=3000

###Success? If the server failed to start, review logs and/or the instructions above. If the server started successfully, open and point a browser to the Tracks host using port 3000, i.e. http://trackshost.mydomain.com:3000, to verify a web page is displayed that prompts for the creation of an admin user account and password. When done, ctrl+c to shutdown Tracks and continue the installation.

##10. Apache2 Update the tracks user directory in preparation for passenger.

$ sudo chmod o+x /home/tracks

###Install Passenger Module

$ passenger-install-apache2-module
	Welcome to the Phusion Passenger Apache 2 module installer, v4.0.44.

	This installer will guide you through the entire installation process. It
	shouldn't take more than 3 minutes in total.

	Here's what you can expect from the installation process:

	 1. The Apache 2 module will be installed for you.
	 2. You'll learn how to configure Apache.
	 3. You'll learn how to deploy a Ruby on Rails application.

	Don't worry if anything goes wrong. This installer will advise you on how to
	solve any problems.

        If you have met the requirements, everything should be green. Accept the defaults 
        to compile which takes quite some time. The installation should complete with the following. 
	--------------------------------------------
	Almost there!

	Please edit your Apache configuration file, and add these lines:

	   LoadModule passenger_module /home/tracks/.rvm/gems/ruby-1.9.3-p547/gems/passenger-4.0.44/buildout/apache2/mod_passenger.so
	   <IfModule mod_passenger.c>
		 PassengerRoot /home/tracks/.rvm/gems/ruby-1.9.3-p547/gems/passenger-4.0.44
		 PassengerDefaultRuby /home/tracks/.rvm/gems/ruby-1.9.3-p547/wrappers/ruby
	   </IfModule>

	After you restart Apache, you are ready to deploy any number of web
	applications on Apache, with a minimum amount of configuration!

	Press ENTER to continue.

	--------------------------------------------

	Deploying a web application: an example

	Suppose you have a web application in /somewhere. Add a virtual host to your
	Apache configuration file and set its DocumentRoot to /somewhere/public:

	   <VirtualHost *:80>
		  ServerName www.yourhost.com
		  # !!! Be sure to point DocumentRoot to 'public'!
		  DocumentRoot /somewhere/public
		  <Directory /somewhere/public>
			 # This relaxes Apache security settings.
			 AllowOverride all
			 # MultiViews must be turned off.
			 Options -MultiViews
			 # Uncomment this if you're on Apache >= 2.4:
			 #Require all granted
		  </Directory>
	   </VirtualHost>

	And that's it! You may also want to check the Users Guide for security and
	optimization tips, troubleshooting and other useful information:

	  /home/tracks/.rvm/gems/ruby-1.9.3-p547/gems/passenger-4.0.44/doc/Users guide Apache.html
	  http://www.modrails.com/documentation/Users%20guide%20Apache.html

	Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
	https://www.phusionpassenger.com

	Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

Create Passenger module conf file and copy and paste.

$ sudo vi /etc/httpd/conf.d/passenger.conf

Copy and paste the following:

LoadModule passenger_module /home/tracks/.rvm/gems/ruby-1.9.3-p547/gems/passenger-4.0.44/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
 PassengerRoot /home/tracks/.rvm/gems/ruby-1.9.3-p547/gems/passenger-4.0.44
 PassengerDefaultRuby /home/tracks/.rvm/gems/ruby-1.9.3-p547/wrappers/ruby
 PassengerDefaultUser apache
</IfModule>

###Static Assets Update Tracks' production.rb static assets to false in preparation for using Passenger with Apache2.

$ vi ~/tracks/config/environments/production.rb

config.serve_static_assets = false

###Apache2 configuration Update apache2 configuration file.

$ sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
$ sudo vi /etc/httpd/conf/httpd.conf

At the bottom of the file, add the following:

<VirtualHost *:80>
  ServerName www.somedomain.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/tracks/tracks/public
  <Directory /home/tracks/tracks/public>
	 # This relaxes Apache security settings.
	 AllowOverride all
	 # MultiViews must be turned off.
	 Options -MultiViews
	 # Uncomment this if you're on Apache >= 2.4:
	 #Require all granted
  </Directory>
</VirtualHost>

###SELinux Configure SELinux to use permissive mode due to Phusion Passenger is going to be blocked by SELinux. Use permissive versus diabled to log passenger activities.

$ sudo vi /etc/selinux/config

Then for this session set SELinux to be permissive or reboot.

$ sudo setenforce 0

Once Tracks installation is complete and been in use for a while, you can create a SELinux module. See the section titled "SELinux Passenger module" below for instructions.

###Firewall & Apache2 Open firewall for Apache by 'customizing' and permitting http or web traffic (80 TCP). You may, also, remove the previous rule for port 3000 TCP.

$ sudo system-config-firewall-tui

Verify changes using:

$ sudo service iptables status

Validate Apache operations by starting the httpd service then using a browser, verify, you are prompted to set admin credentials for Tracks.

$ sudo service httpd start

###Apache at startup Configure Apache to start at boot.

$ sudo chkconfig httpd on

##11. Done(?) At this point you are ready to begin using Tracks.

The basic process is as follows: Create contexts, i.e. work, home, gym, etc. Create projects and specify context. Create actons specifying context and project.

Alternatively, You can simply create an action specifying a new context and new project. Tracks will auto-create them. For example, create an action to 'replace toilet seal' and specify context 'home' and project 'bathroom remodel.'

;) Enjoy!

##12. Other Considerations

##SELinux Passenger module The process that follows can be used for creating security modules for SELinux. Alternatively, you can disable SELinux, but that would be unwise.

SELinux must be set to permissive mode versus disabled to captures events to logs. Either update \etc\selinux\config` as decribed above or execute setenforce.

$ sudo setenforce 0

Restart Apache

$ sudo service httpd restart

Start using your rails application, Tracks.

Later, walk through SELinux's log and generate new SELinux policy module.

$ sudo grep httpd /var/log/audit/audit.log | audit2allow -M passenger

Install newly created SELinux module

$ sudo semodule -i passenger.pp

Set SELinux to enforcing mode. Update /etc/selinux/config or execute setenforce as appropriate.

$ sudo setenforce 1

##Phusion Passenger, Rails, & Sub-URIs In the course of using ruby, rails, and passenger, you may need to create multiple sites or apps not just one. Using Passenger sub-uris will accomplish this task. In addition, when using Nginx (see below), using a sub-uri simplifies configuration and reduces hours of banging your head on your desk.

With Tracks, update the site.yml to use a subdir, then update Apache's configuration to reflect the virtual host shown below. So for www.somedomain.com we will use subdir tracks which result with http://www.somedomain.com/tracks.

Remove the comment '#' and update to read subdir: "/tracks"

$ vi /home/tracks/tracks/config/site.yml

Update the apache2's httpd.conf, existing virtual host stanza, to read as follows:

$ sudo vi /etc/httpd/conf/httpd.conf 

<VirtualHost *:80>
  ServerName trk.harmonson.net
  DocumentRoot /home/tracks/tracks/public

Alias /tracks /home/tracks/tracks/public

  <Location /tracks>
		PassengerBaseURI /tracks
		PassengerAppRoot /home/tracks/tracks
  </Location>

  <Directory /home/tracks/tracks/public>
		 Allow from all
		 # This relaxes Apache security settings.
		 AllowOverride all
		 # MultiViews must be turned off.
		 Options -MultiViews
		 # Uncomment this if you're on Apache >= 2.4:
		 #Require all granted
  </Directory>

</VirtualHost>

Restart Apache for changes to take effect.

$ sudo service httpd restart

##Nginx reverse proxy Nginx is a very efficient web service which I use as a reverse proxy. Below is an example of a working Nginx 1.4 location config using the Tracks build above and sub-uri /tracks. This is only the Nginx /location stanza not a complete nginx.conf configuration file.

### Tracks
location /tracks/ {
		auth_basic "off";

## Set Headers
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto https;

## Tracks Backend
		proxy_pass http://192.168.1.111/tracks/;
		proxy_redirect off;
}
Clone this wiki locally