WordPress in CentOS 7 (nginx, MariaDB, PHP, Redis)

Last revision: 26 of April of 2020

Table of contents

Here we left a small manual you of installation from an installation of basic operating system of CentOS 7.

Forming the Operating system

First it is to make one first update and configuration of the base of the operating system.

yum && clean all yum - and upgrade yum - and install yum-utils curl vim unzip wget yum-config-manager --inable rhui-REGION-RHEL-server-optional rhui-REGION-RHEL-SERVER-extras

Once the operating system is installed, first that we will form will be the hour of the servant. In this case we will form the hour zone of Madrid.

timedatectl set-timezone €˜Europe/Madrid€™ yum - and install NTP systemctl start ntpd systemctl inable ntpd systemctl status ntpd ntpq - p

In order to be able to take advantage of the last versions to the maximum, we will use repositorio alternative EPEL.

yum - and install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum - and install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum - and install https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum yum clean all && - and upgrade

Installation of MariaDB

The following step will be the installation of the data base. In this case we are going to use MariaDB 10.3. First that we will do will be to form the unloading, and later its installation.

curl - foll https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash - s -- --mariadb-server-version=mariadb-10.3 yum clean all && yum - and upgrade yum - and install MariaDB-server MariaDB-client

Now that is installed, we will come to the initial configuration. For it we will use the system safe installation, that it will do some questions to us.


To the question of if we want to change the password, following if we have put or not in the installation, we will change it. In case of not to have put no, is very recommendable to put a safe password to him.

Set root password? [Y/n]: And

The rest of questions, we will answer the following thing:

Remove anonymous users? [Y/n]: And Disallow root login remotely? [Y/n]: And Remove test database and Access to it? [Y/n]: And Reload privilege tables now? [Y/n]: And

At this moment already we will have the data base formed. Now we will cause that one executes in re homes of the system and we will initiate it.

systemctl stop mysql.service systemctl inable mysql.service systemctl start mysql.service

Installation of nginx

At this moment we have the data base formed and are going to come to the installation from the Web server. In this case we are going to use nginx. In order to be, we will not use the version that comes with the operating system, but more updated and maintained.

yum && clean all yum - and upgrade yum - and install nginx

Now that we have nginx installed, we are going it to form so that one automatically begins in re homes of the system.

systemctl stop nginx.service systemctl inable nginx.service systemctl start nginx.service

Installation of PHP

At this moment already we have the Web server, reason why we are going to install and to form PHP so that he correctly works with the Web server and data base. In this case we are going to install version PHP 7.3. First we will make the installation of the up-to-date packages more (than they are not those that come with the operating system) and that in case of needing it, in addition, would allow us to have several versions of PHP in parallel.

yum-config-manager --inable remi-php73 yum clean all && yum - and upgrade yum - and install php73-php php73-php-fpm php73-php-common php73-php-devel php73-php-cli php73-php-bcmath php73-php-pecl-crypto php73-php-gd php73-php-pecl-geoip php73-php-pecl-imagick php73-php-imap php73-php-json php73-php-mbstring php73-php-pecl-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-soap php73-php-sodium php73-php-pecl-ssh2 php73-php-pecl-xdebug php73-php-XML php73-php-xmlrpc php73-php-pecl-zip

Now that already we have installed PHP correctly, we are going to activate it so that when it is reinitiated the system is executed automatically.

systemctl stop php-fpm.service systemctl inable php-fpm.service systemctl start php-fpm.service nginx - t nginx - s reload

Installation of Redis

In order to work with some improvements in the yield of the cache of objects, we are going to let ready Redis as storage system.

yum && clean all yum - and upgrade yum - and install redis php73-php-phpiredis

Later, and of the same form that the rest of elements, we are going it to form so that one begins automatically if the servant is reinitiated.

systemctl stop redis.service systemctl inable redis.service systemctl start redis.service

Configuration of the HTTPS

As we are going to mount our Web on a safe Web server (HTTPS), we will need to install the certificate generator of Let's Encrypt, previously so that we will prepare the systems for the creation of safe keys.

openssl dhparam - out /etc/ssl/certs/dhparam.pem 2048

And at this moment we will install the system of certificate creation certbot.

yum && clean all yum - and upgrade yum - and install certbot-nginx

So that the certificates are updated automatically, we will once activate a task programmed (cron) to the day that automatically renews certificates.

crontab - e

Once inside, we will form, for example, that executes to the 06:45 every morning.

45 6 * * * certbot renew --dry-run

As of this moment we can reinitiate the machine if we want, and we will already have it list to begin its use and to mount the websites.