CentOS/RHEL 7 first deploy: simple, minimal, and functional server

Source: Google Image

Hello, it’s me again. Today I want to share another little experience on the server setup. Just like the title shows you, in this post I want to tell a simple, minimal, functional, yet ready-to-use CentOS/RHEL 7 server. All you need is a computer and CentOS/RHEL 7 image to burn to your USB stick, and of course, internet connection for downloading tools needed for your new little server. In this tutorial I’m using CentOS 7 ISO image which you can download from here.

Note: For RHEL users, you can also follow steps below because the CentOS itself is derived from RHEL and it’s totally free!

First you must install the CentOS 7 on the computer you want to turn into a server. You can choose the minimal server installation for this time, and we will add another tools needed in this tutorial. You can use the “dd” command to burn your ISO image to your USB by following this site.

After the installation complete, follow some steps below to make your server ready-to-use for production environment.

Configure your IP address

First you can change your network configuration easily for your new server by typing:

root@centos:~# nmtui

And make sure you can connect to the internet from your server. You can check them by using ping to Google’s DNS by typing:

root@centos:~# ping

After you connect to the internet, you can continue remaining steps.

Update your machine!

Next step after you connect to the internet is you must update your machine first. You can update (and upgrade) you new CentOS machine by typing as follows:

root@centos:~# yum update

Note: An “update” in CentOS/RHEL is like “upgrade” in Ubuntu and its derivation. But, if you want to do an Ubuntu’s “update” in CentOS/RHEL, you can use:

root@centos:~# yum check-update

Install nano for easy editing

Although you can edit any configuration files using vi, but personally I think vi isn’t recommended for new SysAdmins. You can use nano as an alternative for vi. You can install it by typing:

root@centos:~# yum install nano

Configure your DNS

If you have your own DNS server, you can add them to your server configuration and make them static. You can edit file /etc/resolv.conf and add your DNS server there. For me, this picture is enough.

root@centos:~# nano /etc/resolv.conf

Minimal DNS configuration

Note: You can apply your DNS configuration by restarting your network daemon after editing the file above

Set your hostname

You can change your hostname in many ways, but to make sure, I usually did all the way down to change my hostname without doing a restart. First, edit the network configuration file in /etc/sysconfig/network and add “HOSTNAME” line to register your new hostname. You can type the following command.

root@centos:~# nano /etc/sysconfig/network

Example network configuration file, adding hostname

Then, edit the hostname configuration file (in /etc/hostname) and write down your desired hostname.

root@centos:~# nano /etc/hostname

Hostname configuration file

Note: Make sure you write in the same hostname across these files!

Next, edit another hostname configuration file in /etc/hosts. This file actually lists all known hostname for your server, but now we will only need ourself for this file.

root@centos:~# nano /etc/hosts

Original /etc/hosts file

Change the file above into this:

Edited /etc/hosts file

Next, we will use the command hostnamectl and hostname to change our hostname to a new one. You can follow this:

root@centos:~# hostnamectl set-hostname myserver.domain.com

root@centos:~# hostname myserver.domain.com

Finally, restart your network service to apply the changes you made.

root@centos:~# systemctl restart network

You can check your new hostname by typing:

root@centos:~# hostname

Install GNU Compiler Collection

Next thing to do is make sure you have the latest version of GNU Compiler. This tool is gonna be used when you want to install anything from source (if any). You can get the latest version by typing:

root@centos:~# yum install gcc

If your installed compiler isn’t the latest, yum will tell you about that. Then you can confirm the installation if any version is available from repositories.

Install Nmap

And we go on to the next, nmap installation. With this tool you can scan your entire network from your server, especially for checking your opened port. To install this, follow:

root@centos:~# yum install nmap

Confirm the installation, and your nmap is ready-to-use.

Install and configure your Firewall

Especially for RHEL users, you can first install your Firewall daemon. And for CentOS users, you can follow this step just to make sure your daemon is installed and currently the latest version of it, by typing:

root@centos:~# yum install firewalld

After you install the firewall daemon, you can start it (and make it automatically start after reboot) by typing the following:

root@centos:~# systemctl start firewalld

root@centos:~# systemctl enable firewalld

After that, configure your firewall to open the HTTP and HTTPS port from your server as follows:

root@centos:~# firewall-cmd --permanent --add-service=http

root@centos:~# firewall-cmd --permanent --add-service=https

Finally, apply your configuration by reloading the daemon:

root@centos:~# firewall-cmd --reload

Install Yum Utilities

Next tool is Yum Utilities. This tool provide any functional utilities and plugins for your yum. You can download it as follows:

root@centos:~# yum install yum-utils

Add some repositories

The last thing, is add some extra repositories. In this step we’re going to add 3 additional repo, that’s EPEL release, IUS release, and REMI release. FYI, EPEL stands for Extra Package for Enterprise Linux. First thing to do is you can download the RPM files by using wget or curl (though if you’re using wget you can download it first by typing yum install wget). Here, I’m using wget, as follows:

root@centos:~# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm

root@centos:~# wget https://dl.iuscommunity.org/pub/ius/stable/Redhat/7/x86_64/ius-release-1.0-15.ius.el7.noarch.rpm

root@centos:~# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Note: RPM files above is only for CentOS/RHEL 7. For version 6 or before, you can find the RPM first by browsing in Google and then download it :)

Next, add the repo to our server, by issuing:

root@centos:~# rpm -ivh epel-release-7–10.noarch.rpm

root@centos:~# rpm -ivh ius-release-1.0–15.ius.el7.noarch.rpm

root@centos:~# rpm -ivh remi-release-7.rpm

Finally, update our server and we have our new server!

root@centos:~# yum update

Optional: Make your internal IP address static

This step is optional. This means you can follow it or not, it’s really your choice. This step is gonna make your internal IP address static by editing the interface configuration file. But first, you must know your interface name by typing:

root@centos:~# ip addr show

See the interface name and remember it, because we’re gonna use it next. Then edit the configuration file in /etc/sysconfig/network-scripts/ifcfg-<interface name>. In my case, it should be like this:

root@centos:~# nano /etc/sysconfig/network-scripts/ifcfg-enp2s0

Add or edit some line below:


Save it, and restart your network service.

root@centos:~# systemctl restart network

And finally, you got your static internal address for product development :)

Yap, I think this is enough. Actually I wrote this post based on another’s post, and that is “30 Things to Do After Minimal RHEL/CentOS 7 Installation” by Tecmint. You can also follow them if you feel my “minimal things to do” here is insufficient for you, and the link goes here. Thanks for reading :)

Tech hobbyist, Learn from scratch, Learning the hard way, Just want to share anything