CentOS 7 - Initial Setup

Update & Repositories

# yum check-update
# yum -y update
# find /etc/ -name "*.rpmnew"
# yum -y install mc vim unzip git bind-utils telnet traceroute wget

Fix CentOS7.5 pythonurl3 update problem

# rm -rf /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname*
# yum -y update
# yum -y reinstall python-backports-ssl_match_hostname

Install EPEL repo

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
# yum -y install epel-release
# yum -y update

Install Remi php72 repo

# cd
# wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# rpm -Uvh remi-release-7.rpm
# vim /etc/yum.repos.d/remi-php72.repo
[remi-php72]
enabled=1

# rm -f ./remi-release-7.rpm

Configuration

Make sure SSH key auth is allowed:

# vim /etc/ssh/sshd_config
...
PubkeyAuthentication yes
...
PasswordAuthentication yes
...

Adding ability elevated user to sudo as root:

# vim /etc/sudoers
...
elevated ALL=(ALL:ALL) NOPASSWD: ALL
...

Add necessary options to basic CentOS7 vimrc

# vim /etc/vimrc
...
set paste
set laststatus=2
set confirm
set visualbell
set t_vb=
set shiftwidth=4
set tabstop=4
nnoremap <C-L> :nohl<CR><C-L>
au BufRead,BufNewFile *.twig set filetype=html
colorscheme default

Add export variables for all users:

# vim /etc/profile
...
export EDITOR=vim
export VISUAL=vim

Hostname

You can check what hostname is set up:

# hostnamectl status

And you can set hostname with:

# hostnamectl set-hostname server1.example.com
# hostnamectl status

Timezone

# timedatectl
# timedatectl list-timezones
...
# timedatectl set-timezone America/New_York
# timedatectl

Set correct time

# yum -y install ntp ntpdate

# systemctl start ntpd
# systemctl enable ntpd
# systemctl status ntpd

# ntpdate -u -s 0.centos.pool.ntp.org 1.centos.pool.ntp.org 2.centos.pool.ntp.org
# systemctl restart ntpd

# timedatectl

# hwclock -w

Allow cron to root

# vim /etc/security/access.conf

...
+:root:cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6

# pwconv

Set up static IP on network interface (private vlan)

# ip addr
# vim /etc/sysconfig/network-scripts/ifcfg-eth1
#static interface setup
BOOTPROTO=static
DEVICE=eth1
HWADDR=22:aa:22:aa:22:aa
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPADDR=192.168.1.1
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=1.0.0.1
DNS2=1.1.1.1
DNS3=8.8.4.4
ZONE=internal

# systemctl restart network
# ip addr

Disable SELinux

# sestatus
# vim /etc/sysconfig/selinux
SELINUX=disabled

# reboot

Add swap

Check current swap and free space on disk:

# swapon -s
# df -h

Create swap file and add it to swap:

# dd if=/dev/zero of=/swapfile count=16 bs=1GiB
# ls -lh /swapfile
# chmod 600 /swapfile
# mkswap /swapfile
# swapon /swapfile

# swapon -s

Make it permanent:

# vim /etc/fstab

/swapfile   swap    swap    sw  0   0