====== The only difference ======
https://wiki.exphosted.com/doku.php/setup_tincan_server ##Existing old version##
The only difference in the versions of below.
Centos 6.5
ruby - ruby 2.1.5p273
ruby gems - 2.4.5
Bundler - 1.7.9
capistrano - 3.3.5
=== Base system ====
- install centos 6.5
=== Extend Repositories and update===
1. Install epel source.
yum install epel-release
2. Update system
yum update -y
=== Install Dev Libraries ===
yum groupinstall "Development Tools" -y
yum groupinstall "Additional Development" -y
yum install gcc gcc-c++ make libtool libxml libxml-devel libxslt libxslt-devel subversion curl-devel java-1.7.0-openjdk java-1.7.0-openjdk-devel git-core openssl-devel patch libyaml-devel patch libffi-devel bison -y
wget http://vault.centos.org/6.5/updates/x86_64/Packages/ImageMagick-devel-6.5.4.7-7.el6_5.x86_64.rpm
wget http://vault.centos.org/6.5/updates/x86_64/Packages/ImageMagick-6.5.4.7-7.el6_5.x86_64.rpm
yum install ImageMagick-6.5.4.7-7.el6_5.x86_64.rpm ImageMagick-devel-6.5.4.7-7.el6_5.x86_64.rpm -y
==== Install Database ====
1. Create a dedicated group and user
groupadd mysql
useradd -r -g mysql mysql
vi /etc/yum.repos.d/mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/5/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/5/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/5/$basearch/
enabled=0
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
vi /etc/yum.repos.d/mysql-community-source.repo
[mysql-connectors-community-source]
name=MySQL Connectors Community - Source
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/5/SRPMS
enabled=0
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql56-community-source]
name=MySQL 5.6 Community Server - Source
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/5/SRPMS
enabled=0
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community-dmr-source]
name=MySQL 5.7 Community Server Development Milestone Release - Source
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/5/SRPMS
enabled=0
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
rpm -qa | grep mysql
#remove if already mysql package installed remove below commands
yum remove mysql-libs-5.1.73-8.el6_8.x86_64 mysql-5.1.73-8.el6_8.x86_64 mysql-devel-5.1.73-8.el6_8.x86_64
yum install cronie cronie-anacron crontabs
yum install mysql-community-server mysql-community-devel mysql-community-release -y
/etc/init.d/mysqld start
/usr/bin/mysqladmin -u root -hlocalhost password 'xxxx' #pwd reset
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
chkconfig mysqld on
==== Install Tomcat and Solr ====
1. Verify that java is installed
java
2. Add tomcat User and Unpack tomcat
To make things easier, we have copied the already configured copy on Tomcat and Solr on server;
Just Untar the following file to /opt directory;
ftp://qacollab01.exphosted.com/softrepo/tincan/opt_combo.tgz
Obsolete method if the above step does not work;
mkdir /opt/tomcat7
useradd tomcat
usermod -m -d /opt/tomcat7 tomcat
cd /opt/tomcat
wget --user=expbbbu --password= ftp://qacollab01.exphosted.com/softrepo/tincan/installed-software/apache-tomcat-7.0.54.tar.gz | tar xz
chown -R tomcat:tomcat /opt/tomcat7
Init script.
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
#JAVA_HOME=/usr/java/jdk1.7.0_05
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/opt/tomcat7/bin
case $1 in
start)
/bin/su tomcat $CATALINA_HOME/startup.sh
;;
stop)
/bin/su tomcat $CATALINA_HOME/shutdown.sh
;;
restart)
/bin/su tomcat $CATALINA_HOME/shutdown.sh
/bin/su tomcat $CATALINA_HOME/startup.sh
;;
status)
test "$(ps -ef|grep java|grep -i catalina 2>1)" && echo "Tomcat-Solr is running" || echo -e "\e[31m\e[0mTomcat-Solr is not running"
;;
esac
exit 0
chmod +x /etc/init.d/tomcat7
chmod 755 /etc/init.d/tomcat7
chkconfig --add tomcat7
chkconfig tomcat on
3. Unpack solr
mkdir /opt/solr && cd /opt/solr
wget --user=expbbbu --password= ftp://qacollab01.exphosted.com/softrepo/tincan/installed-software/solr-4.8.1.zip
unzip solr-4.8.1.zip
cp -r solr/example/lib/ /opt/tomcat/lib/
chown -r tomcat:tomcat /opt/solr
4. Configure Solr
- Data Dir:
nano /opt/solr/example/solr/conf/solrconfig.xml
Create a shared data or a local data drive and set the path here. \\
Also, copy Learnexa schema.xml.
- Configure Tomcat.
# for multicore
cd /opt/tomcat7
mkdir -p Catalina/localhost
nano solr.xml
Then add:
==== Application Runtime Dependencies ====
=== Create application user ===
/usr/sbin/adduser "expdev01"
#set regular password
=== Log out as root and login as application user created above ===
=== Install RVM ===
1. Ensure:
whoami
#expdev01
vi ~/.profile
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
vi ~/.bashrc
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
2. Install RVM
\curl -sSL https://get.rvm.io | bash
3. Install and use Ruby 2.1.5
rvmsudo rvm install 2.1.5
rvmsudo rvm use 2.1.5
sudo gem update --system 2.4.5
4. Verify
which ruby
#/home/expdev01/.rvm/rubies/ruby-2.1.5/bin/ruby
=== Setup Bundler and Gems ====
gem install rails -v '4.2.6'
gem install bundler -v '1.11.2'
gem install eventmachine -v '1.0.7'
gem install mysql2 -v '0.3.18'
gem install nokogiri -v '1.6.6.2'
gem install rake -v '10.4.1'
gem install rack -v '1.6.0'
gem install passenger -v '4.0.44'
gem install capistrano-bundler -v '1.1.4'
gem install capistrano-ext -v '1.2.1'
gem install capistrano-log_with_awesome -v '0.0.2'
gem install capistrano-passenger -v '0.0.2'
gem install capistrano-rails -v '1.1.1'
gem install capistrano-rvm -v '0.1.1'
=== Setup Nginx ===
rvmsudo passenger-install-nginx-module
==== Deploy Application ====
Following are the steps to be followed. Please note that "development" needs to be replaced with "staging"/"production" based on the environment you are setting up.
download file from 107.170.68.123:/soft/deploy-bk.tar.gz
unzip deploy-bk.tar.gz
mv deploy-bk /deploy
chown -R expdev01:expdev01 /deploy
download file from 107.170.68.123:/soft/nginx.conf
Replace the file /opt/nginx/conf/nginx.conf
cd /home/expdev01
mkdir tincan
cd tincan
bundle exec cap install
mv tincan tincan-old
download file from 107.170.68.123:/soft/home-bkup.tar.gz
tar xvf home-bkup.tar.gz
download file from 107.170.68.123:/soft/capistrano.zip
cd /home/expdev01/tincan/lib/
unzip capistrano.zip
download file from 107.170.68.123:/soft/bin.zip
cd /home/expdev01/
unzip bin.zip
chown -R expdev01:expdev01 /home/expdev01
=== Configure the app and DB ===
cd /deploy/tincan/current/
# Specify the flavor of the app in config/environments/development.rb
DEFAULT_FLAVOR = "expertusone" #(Or "learnexa" depending on for whom you are setting up.)
#update databased details in config/database.yml development stanza.
#Specify makara gem configs, if you are adding a slave db.
#run the below -
bundle install
bundle exec rake db:create RAILS_ENV=development
bundle exec rake db:migrate RAILS_ENV=development
bundle exec rake db:seed RAILS_ENV=development
vi config/environments/development.rb
APP_URL = "http://devlrs01.learnexa.com"
API_URL = "http://devlrs01.learnexa.com"
Note make sure added /etc/hosts entry if not have public dns
Restart apache.
=== Deploy scripts changes ===
Download file from 107.170.68.123:/home/expdev01/tincan/runcap.sh
Change the tincan directory files as needed with environment and db values.
sh /home/expdev01/tincan/runcap.sh
=====Local gems=====
gem list ##will get below output for reference added
actionmailer (4.1.8, 3.2.17)
actionpack (4.1.8, 3.2.17)
actionview (4.1.8)
activemodel (4.1.8, 3.2.17)
activerecord (4.1.8, 3.2.17)
activerecord-deprecated_finders (1.0.3)
activeresource (3.2.17)
activesupport (4.1.8, 3.2.17)
arel (5.0.1.20140414130214, 3.0.3)
authlogic (3.4.5, 3.4.2)
bigdecimal (1.2.4)
builder (3.2.2, 3.0.4)
bundler (1.7.9)
bundler-unload (1.0.2)
capistrano (3.3.5)
capistrano-bundler (1.1.4)
capistrano-ext (1.2.1)
capistrano-log_with_awesome (0.0.2)
capistrano-passenger (0.0.2)
capistrano-rails (1.1.1)
capistrano-rvm (0.1.1)
capistrano-stats (1.1.1)
climate_control (0.0.3)
cocaine (0.5.7, 0.5.4)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.7.0)
colorize (0.7.5)
daemon_controller (1.2.0)
daemons (1.2.2, 1.1.9)
domain_name (0.5.23)
erubis (2.7.0)
eventmachine (1.0.7, 1.0.3)
execjs (2.5.0, 2.0.2)
executable-hooks (1.3.2)
faraday (0.9.1, 0.9.0)
ffi (1.9.8)
ffi-compiler (0.1.3)
gem-wrappers (1.2.7)
haml (4.0.6, 4.0.3)
haml-rails (0.6.0, 0.4)
hash-deep-merge (0.1.1)
highline (1.6.21)
hike (1.2.3)
hpricot (0.8.6, 0.8.3)
html2haml (2.0.0)
html_truncator (0.4.0)
htmlentities (4.3.3, 4.2.2)
http-cookie (1.0.2)
httpauth (0.2.1)
i18n (0.7.0, 0.6.9)
io-console (0.4.2)
iso8601 (0.8.5, 0.4.1)
journey (1.0.4)
jquery-rails (3.1.2, 3.1.0)
json (1.8.2, 1.8.1)
json_pure (1.8.2, 1.8.1)
jwt (1.4.1)
lazy_high_charts (1.5.4)
libv8 (3.16.14.7 x86_64-linux, 3.16.14.3 x86_64-linux)
mail (2.6.3, 2.5.4)
mime-types (2.4.3, 1.25.1)
mini_portile (0.6.2)
minitest (5.5.1, 4.7.5)
multi_json (1.11.0, 1.0.4)
multi_xml (0.5.5)
multipart-post (2.0.0)
mysql2 (0.3.18, 0.3.15)
net-scp (1.2.1)
net-ssh (2.9.2)
netrc (0.10.3)
nokogiri (1.6.6.2, 1.5.9)
oauth (0.4.7, 0.4.6)
oauth2 (1.0.0, 0.6.0)
options (2.3.2)
paperclip (4.2.1, 2.8.0)
paranoia (2.1.1, 1.3.3)
passenger (4.0.44)
polyglot (0.3.4)
pr_geohash (1.0.0)
progress_bar (1.0.3)
protected_attributes (1.0.8)
prototype-rails (4.0.0, 3.2.1)
psych (2.0.5)
rabl (0.11.6, 0.3.0)
rack (1.6.0, 1.5.2, 1.4.5)
rack-cache (1.2)
rack-ssl (1.3.4)
rack-test (0.6.3, 0.6.2)
rails (4.1.8, 3.2.17)
rails_autolink (1.1.6)
railties (4.1.8, 3.2.17)
rake (10.4.1, 10.3.1, 10.1.0)
rdoc (4.2.0, 4.1.0, 3.12.2)
rdoc-data (4.0.1, 3.12)
ref (1.0.5)
request_store (1.1.0, 1.0.5)
rest-client (1.8.0, 1.6.7)
rmagick (2.14.0, 2.13.1)
rsolr (1.0.12, 1.0.10)
ruby_parser (3.6.5, 3.6.0)
rubygems-bundler (1.4.4)
rubygems-update (2.4.5)
rvm (1.11.3.9)
sass (3.3.7, 3.2.19)
sass-rails (4.0.5, 3.2.6)
scrypt (1.2.1)
sexp_processor (4.5.0, 4.4.3)
simple_uuid (0.4.0)
sprockets (2.12.3, 2.2.2)
sprockets-rails (2.2.4)
sshkit (1.7.1)
sunspot (2.1.1)
sunspot_rails (2.1.1)
sunspot_solr (2.1.1)
test-unit (2.1.5.0)
therubyracer (0.12.2, 0.12.1)
thin (1.6.3, 1.6.2)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
treetop (1.4.15)
tzinfo (1.2.2, 0.3.39)
uglifier (2.7.1, 2.5.0)
unf (0.1.4)
unf_ext (0.0.6)
will_paginate (3.0.6, 3.0.5)
====== Headline ======
vi /etc/init.d/nginx ##paste below content save and chmod +x /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/opt/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac