Eric Guo's

in HTML5, JavaScript, Ruby & Rails, Python, and Cloud MES!

CentOS Rails Server With Oracle on VMware Installation Log


First CentOS server installed in VMware as thape SSO server.

Install software in root account

Update system

Run as root:

yum update
yum install -y git zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
rpm -ivh epel-release-latest-7.noarch.rpm
yum --enablerepo=epel install htop

As VMware admin required, not disable the PermitRootLogin in /etc/ssh/sshd_config

Setup a user account

adduser deployer
gpasswd -a deployer wheel
visudo # add deployer ALL=(ALL) NOPASSWD: ALL at end
sudo su - deployer
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

Also disable root login and password via PermitRootLogin in /etc/ssh/sshd_config

Before exis, make sure you can login via ssh deployer@ip_address, other wise, check file permission.

Install rbenv and ruby-build

cd # as a deployer
git clone .rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init
# As an rbenv plugin
mkdir -p "$(rbenv root)"/plugins
git clone "$(rbenv root)"/plugins/ruby-build
git clone "$(rbenv root)"/plugins/rbenv-china-mirror

Install Ruby 2.6.5

rbenv install -l
rbenv install 2.6.5
rbenv global 2.6.5
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem install bundler -v 1.17.3

Install Javascript Runtime

Run as root:

curl -sL | bash -
sudo yum install nodejs
curl -sL | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
# if you behind GFW
# But notice sometime some packages not sync so restore back via
# npm config set registry --global
npm config set registry --global
npm config set disturl --global
# Sometime taobao is out of sync, so still need official registry.
# yarn config delete registry --global
yarn config set registry --global
yarn config set disturl --global

Install nginx

sudo yum install epel-release
sudo yum install nginx
chkconfig nginx on
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload

Fix permission for CentOS

sudo mkdir /var/www
cd /var/www
sudo mkdir cybros
sudo chown deployer:deployer cybros/

and disable selinux(,

or further read nginx permission denied

Install Oracle Instant Client

Download Version and following ruby-oci8 document

sudo rpm -i ./oracle-instantclient12.2-basic-
sudo rpm -i ./oracle-instantclient12.2-devel-
sudo rpm -i ./oracle-instantclient12.2-sqlplus-
cd /usr/local/bin
sudo ln -s /usr/bin/sqlplus64 sqlplus
export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
gem install ruby-oci8
Append to ~/.bashrc
export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
export NLS_LANG=en_US.UTF-8

Install FreeTDS to connect to SQL Server

sudo su -
tar -xzf freetds-1.00.111.tar.gz
cd freetds-1.00.111
./configure --prefix=/usr/local --with-tdsver=7.3
make install
logout # as deployer
gem install tiny_tds

Install MySQL

Install the percona server via yum.

After install, do the secure installation for root.

mysql -u root -p
CREATE DATABASE cybros_prod character set UTF8mb4 collate utf8mb4_bin;
CREATE USER 'cybros_prod'@'localhost' IDENTIFIED BY 'new_password';
GRANT ALL ON cybros_prod.* TO 'cybros_prod'@'localhost';