Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

CentOS Rails Server With Oracle on VMware Installation Log

Permalink

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 git-lfs zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum --enablerepo=epel install htop
reboot

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 https://github.com/sstephenson/rbenv.git .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 https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
git clone https://github.com/andorchen/rbenv-china-mirror.git "$(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 https://rpm.nodesource.com/setup_10.x | bash -
sudo yum install nodejs
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | 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 https://registry.npmjs.com/ --global
# npm config delete disturl --global
npm config set registry https://registry.npmmirror.com/ --global
npm config set disturl https://npmmirror.com/dist --global
# Sometime taobao is out of sync, so still need official registry.
# yarn config delete registry --global
yarn config set registry https://registry.npmmirror.com/ --global
yarn config set disturl https://npmmirror.com/dist --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(https://linuxize.com/post/how-to-disable-selinux-on-centos-7/),

or further read nginx permission denied

Install Oracle Instant Client

Download Version 12.2.0.1.0 and following ruby-oci8 document

sudo rpm -i ./oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
sudo rpm -i ./oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
sudo rpm -i ./oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
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=AMERICAN_AMERICA.AL32UTF8

Install FreeTDS to connect to SQL Server

sudo su -
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.111.tar.gz
tar -xzf freetds-1.00.111.tar.gz
cd freetds-1.00.111
./configure --prefix=/usr/local --with-tdsver=7.3
make
sudo 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 pp_prod character set UTF8mb4 collate utf8mb4_0900_ai_ci;
CREATE USER 'pp_vendor'@'localhost' IDENTIFIED BY 'new_password';
GRANT ALL ON pp_prod.* TO 'pp_vendor'@'localhost';
FLUSH PRIVILEGES;

Comments