TECH

Vol.39

author

Engineer

Y.M.

Let’s Install a High-Performance Web Server on CentOS 7! — Preparation Guide

#WEB#webサイト#blogging software#programming
This time, we’ll be talking about setting up a web server.
stuffstuff

Introduction

When you want to publish a website, you need a web server environment.
At that point, shared hosting services are usually the easiest and most straightforward option.
However, while they are simple to use, they can become limiting when you want to do more advanced things or customize the environment, making them less flexible overall.
In addition, because multiple users share the same server environment, your website may be affected by the traffic of other users’ sites. For example, if another user’s site receives excessive traffic, server resources may be allocated to that site, causing your own website to slow down.

If you want complete freedom to customize the environment, you need root privileges for the operating system, meaning an environment where you have full control over the OS itself.
In the past, dedicated servers were one option for this, but compared to shared hosting they were expensive and not something most people could casually use.

Recently, however, affordable services that allow you to use environments on an OS-by-OS basis have become increasingly common.
With the rise of services such as VPS and cloud servers, server hosting options have diversified, making it much easier to create the server environment you envision.
In this article, we’ll build an environment for publishing websites using :contentReference[oaicite:0]{index=0}, one of the many Linux distributions available.

Let’s Start Configuring the Server

The web server setup will be performed remotely from a Mac.
The server operating system used in this guide is :contentReference[oaicite:0]{index=0} 7.

The operating systems available may vary depending on the hosting service, but in most cases you will choose between a Windows-based server (Hyper-V) or a :contentReference[oaicite:1]{index=1}-based server (KVM).
With Linux servers, you can often freely choose the OS distribution and version, and some services even allow you to mount and install an OS ISO image directly.
*Be aware that depending on the OS version, some hosting providers may not offer technical support.

We will connect remotely through SSH using the Terminal application and perform the configuration from there.
There are many other SSH remote login tools available, but Terminal is intuitive, simple, and easy to use, so we’ll proceed with that.

What Is a Distribution?

There are many different types of :contentReference[oaicite:0]{index=0}.
Because Linux is open source and developed by many different contributors, there are countless variations available.
Popular distributions also tend to vary depending on the country and region.
In Japan, :contentReference[oaicite:1]{index=1} has traditionally been one of the most widely used distributions for server environments. :contentReference[oaicite:2]{index=2} is also very popular.
When choosing a server distribution, important factors include stability, security, and update frequency (whether active development is continuing). In general, selecting a distribution with a large user base is often the safest choice.

Logging In with SSH

First, make sure you have completed the following setup steps.

  • Set up public key authentication (server side)
  • Obtain and place the private key (local side)

Many :contentReference[oaicite:0]{index=0} and cloud services only allow login via :contentReference[oaicite:1]{index=1}.
In such cases, you can usually download the key file from the server’s control panel.
Place the private key in the following directory on your Mac:
User root/.ssh/

Change the permissions of the .ssh directory to 700.

$ chmod 700 ~/.ssh

Change the permissions of the private key file to 600.

$ chmod 600 ~/.ssh/(your_private_key_name)

Once you have completed these settings, try logging in.

$ ssh -i key_directory/key_file username@server_host (IP address or domain)

For example:

$ ssh -i ~/.ssh/id_rsa [email protected]

After successfully logging in, we can begin the installation process.

Installing Nginx

Install the web server :contentReference[oaicite:0]{index=0}.
Use the following commands for the installation.

# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# yum install nginx

The first command adds the nginx repository using the rpm command, and the second installs nginx using the yum command.

Installing PHP-FPM

Next, install the :contentReference[oaicite:0]{index=0} related packages.
The version to be installed will be the latest PHP 7 series.

# wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# rpm -Uvh remi-release-7.rpm

Since the latest version of PHP cannot be installed from the default repository, the Remi repository is added.

# yum --enablerepo=remi --enablerepo=remi-php70 install php php-fpm php-mysqlnd php-gd php-mbstring php-pdo

If necessary, install all required dependency packages as well.
This completes the installation of the PHP-related packages.

Installing MariaDB

Next, install :contentReference[oaicite:0]{index=0}.
MariaDB is developed by a project that forked from :contentReference[oaicite:1]{index=1}, making it compatible with MySQL.
In general, you can operate it much like MySQL.
It works without issues for running :contentReference[oaicite:2]{index=2}.
To install the latest version, add the repository first.

# vi /etc/yum.repos.d/mariadb.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1.10/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

After saving the file, run the following command to install it.

# yum install mariadb mariadb-server

This completes the basic installation.

Summary

In this “Preparation Guide,” we logged into the server via :contentReference[oaicite:0]{index=0} using Terminal and installed the various components required for a web server environment.
With the standard packages included in :contentReference[oaicite:1]{index=1}, it is often not possible to install the latest versions, so additional repositories must be added manually.
This time, we focused on installing the latest versions available through yum.
There is also a method for building software directly from source code, which we hope to introduce another time.
In the next article, the “Configuration Guide,” we’ll actually configure these components and make the website accessible through the browser.

Reference: Installing the latest version of nginx on CentOS using yum

Reference: Installing LAMP (Apache + MariaDB/MySQL + PHP) on CentOS 7 and running WordPress (Apache edition)

Reference: Adding the Remi repository to the yum repository on CentOS 7.1 64bit

Reference: Installing the latest version of MariaDB on CentOS using yum

Reference: Choosing a library (mysqlnd)

PREV
Vol.38Useful Web Analytics Tool to Kno…
NEXT
Vol.40Expressing Fur Texture in Digita…

MORE FOR YOU