Eric Guo's

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

Rbenv and CentOS Ruby on Rails Production Environment Install Log


Original refer, install on a Aliyun server.

Install software in root account

Update system

yum update
yum install -y htop 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

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

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 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 "$(rbenv root)"/plugins/ruby-build

Install Ruby 2.5.1

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

Install Javascript Runtime

curl --silent --location | sudo bash -
sudo yum install nodejs
sudo curl -sL -o /etc/yum.repos.d/yarn.repo
sudo yum install yarn

Install postgresql

sudo yum install postgresql-server postgresql-contrib postgresql-devel
sudo postgresql-setup initdb
sudo systemctl start postgresql
createuser deployer --pwprompt
CREATE DATABASE harman_vendor_production WITH ENCODING='UTF8' OWNER=deployer;
# "local" is for Unix domain socket connections only
local all all peer
psql -d harman_vendor_production

Install nginx

sudo yum install epel-release
sudo yum install nginx

Fix permission for CentOS

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

or further read nginx permission denied