Sei sulla pagina 1di 3

# CentOS Setup for Ruby on Rails(RoR)

After the creation of VPS, first thing to follow:


## Network setup
Configure for static ip on `/etc/sysconfig/network-scripts/`
```bash
$ vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.0.000
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=8.8.8.8
DNS2=1.1.1.1
```
Restart the network to accept changes
```bash
$ systemctl restart network
```
## Update the system.
```bash
$ yum update -y
```
## Install epel.
```bash
$ yum install epel-release -y
```
## Install nginx [^2]
[^2]:https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-
centos-7
```bash
$ yum install nginx -y
```
## Install PostgreSQL 11 [^1]
[^1]:https://www.symmcom.com/docs/how-tos/databases/how-to-install-postgresql-11-x-
on-centos-7
```bash
$ rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-
latest.noarch.rpm
$ yum install postgresql11-devel postgresql11-server postgresql11 -y
$ /usr/pgsql-11/bin/postgresql-11-setup initdb # Initialize database
```
## Install rbenv requirements
```bash
$ yum install -y \
git \
zlib \
zlib-devel \
gcc-c++ \
patch \
readline \
readline-devel \
libyaml-devel \
libffi-devel \
openssl-devel \
make \
bzip2 \
bzip2-devel \
autoconf \
automake \
libtool \
bison \
curl \
sqlite-devel
```

## Create deployment user with sudo


```bash
$ adduser username
$ passwd username
```
## Give user root privilege
```bash
$ usermod -aG wheel deploy
```
## Passwordless sudo
```bash
$ visudo
*Add below line after #includedir /etc/sudoers.d*
deploy ALL=(ALL) NOPASSWD:ALL
```
## Install rbenv
```bash
$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
```
## Install Ruby
```bash
$ rbenv install -v 2.5.1
$ rbenv global 2.5.1
$ gem install bundler
$ rbenv rehash
```
## Configure firewall for http/https
```bash
$ firewall-cmd --permanent --zone=public --add-service=http
$ firewall-cmd --permanent --zone=public --add-service=https
$ firewall-cmd --reload
```

## Install pyenv dependencies


```bash
yum install -y \
@development \
zlib-devel \
bzip2 \
bzip2-devel \
readline-devel \
sqlite \
sqlite-devel \
openssl-devel \
xz \
xz-devel \
libffi-devel \
findutils
```
## Install pyenv via git clone
```bash
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
```
## Define environment variables
```bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
```
## Initialize pyenv
```bash
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi'
>> ~/.bash_profile
```

Potrebbero piacerti anche