
Doing Something With a Server: OS Configuration
- Written by John
- Aug 2nd, 2018
You’ve more than likely not read the previous article giving you an introduction into this series. Nonetheless, we shall power on.
This article will guide you through configuring the date and time and adding the required repos for installation later on.
Environment
Throughout the whole of this series, I will be using an Amazon Linux EC2 2018.03 t2.nano environment. There shouldn’t be many differences between this environment and yours unless you’re using a different Linux distro or operating system. If you are, Google will be your friend.
The majority of tasks completed in this series will be done by CLI via Putty. I will be connecting to my EC2 instance via SSH (Secure Shell). If your installation uses a GUI, open up your terminal.
Updating Your OS
One of the first things to do after logging into your environment is to ensure all packages and updates are applied to your OS. In Amazon Linux and CentOS you can run the following command.
sudo yum update
Setting the Date & Time
More than likely the date and time in your OS is configured for a US timezone. This is usually the norm and you may need to change the time your OS is running on if you’re in a different timezone. This is done by applying a different timezone to the OS. You can check the current date and time by running the date command.
date
First, you’ll need to find the timezone you are wanting to use. This could be a timezone you are living in or a certain timezone you want to stay in sync with.
sudo ls -lash /usr/share/zoneinfo
Once you’ve found the correct area/timezone, you’ll need to apply the timezone to the OS. First, you’ll need to remove the current timezone then apply the correct timezone.
sudo rm -f /etc/localtime
sudo ln -s /usr/share/zoneinfo/GB /etc/localtime
Check if the correct date and time has applied to your OS by running the date command.
Please note, when looking for your timezone, there are some timezones in folders where an area or region has different timezones. For example, Europe has the folder Europe and the United States has the folder US.
Adding Repos
Using repos or repositories is an easy way to install applications and to keep them up to date. I prefer to use a repo where I can. We will be adding a repo for each application listed in the overview article, except for Lets Encrypt and SSH. All repos are located in the /etc/yum.repos.d/ folder.
For each repo we need to create a repo file into the above location. Each repo below will have a file and details of the location of the repo. Copy and paste the repo details into the file you create.
Webmin
sudo vi /etc/yum.repos.d/Webmin.repo
[Webmin] name=Webmin Distribution Neutral baseurl=https://download.webmin.com/download/yum mirrorlist=https://download.webmin.com/download/yum/mirrorlist enabled=1
After creating the repo file you will need to import the Webmin key to allow you to install it from the repo. If the key is missing, you will receive an error. To import the key, use the following command.
sudo rpm --import http://www.webmin.com/jcameron-key.asc
For more details on installing Webmin, go to the Webmin RPM installation page.
OpenLitespeed
Running the below command will automatically add the repo into the repos folder. This repo is for the Amazon Linux OS.
sudo wget http://rpms.litespeedtech.com/centos/litespeed.repo -P /etc/yum.repos.d/
The repo file for OpenLitespeed requires modifying on Amazon Linux as it will try to retrieve OpenLitespeed from an invalid URL. Open the file /etc/yum.repos.d/litespeed.repo. Replace the $releasever variable with the number 6. You should have something similar to the below.
[litespeed]
name=LiteSpeed Tech Repository for CentOS 6 - $basearch
baseurl=http://rpms.litespeedtech.com/centos/6/$basearch/
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=http://rpms.litespeedtech.com/centos/RPM-GPG-KEY-litespeed
[litespeed-update]
name=LiteSpeed Tech Repository for CentOS 6 - $basearch
baseurl=http://rpms.litespeedtech.com/centos/6/update/$basearch/
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=http://rpms.litespeedtech.com/centos/RPM-GPG-KEY-litespeed
For more details on installing OpenLitespeed, including installing other repos, go to the OpenLitespeed installation page.
MariaDB
sudo vi /etc/yum.repos.d/MariaDB_10.3.repo
# MariaDB 10.3 CentOS repository list - created 2018-08-26 16:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
For more details on installing MariaDB repos or version, go to the MariaDB repo page.
Caching the Repos
This step isn’t needed. I do this to ensure the repos are working as expected. If there are any issues now I can resolve them, instead of resolving the issue as I’m installing the application(s).
sudo yum repolist
Lets Encrypt (Certbot)
Lets Encrypt is a cool technology where you can request for SSL certificates at no cost. It is great for those that need a certificate to get something up and running quickly.
Please note, if you require any warranty or additional benefits that you receive from other certificate providers, please use them as Lets Encrypt is not intended for this.
Because we will be using OpenLitespeed the Certbot does not integrate into it quite as well as Apache or Nginx. Therefore, we need to download the application to a folder location and run it from there. I usually download the file into my user folder as I am the only user on the server. If you have other users that need to use this please download it into an appropriate location. Throughout this guide, I will download it to /home/$USER/.
sudo wget https://dl.eff.org/certbot-auto
Once downloaded, we need to apply the correct permissions.
sudo chmod a+x certbot-auto
For more information, go to the Lets Encrypt and Certbot pages.
We’re now at a point where we can start to install and configure applications. In the next article, we will be focusing on SSH (Secure Shell). It is important that we configure SSH as we do not want malicious entities abusing and potentially logging in to the server.