Thursday, 27 June 2019

Install Wordpress 5 on CentOS 7 LAMP Server

Install Wordpress 5 on CentOS 7 LAMP Server

Wordpress ( is a free and open-source content management system. Wordpress is developed in PHP and has a plugin architecture and template system. It is mostly used for blogs but can also be used for other type of web contents like mailing lists, forums, media gallery and online stores. Wordpress is the most popular content management system in use. It is used by more than 60 million websites.

In this article, we will install Wordpress 5 on CentOS 7 based LAMP server. First, we install and configure LAMP server components and then we will deploy Wordpress on it.

This article emphasize on the installation of a Wordpress environment. If you want to create and customize your Wordpress site then Professional WordPress: Design and Development by Wrox is a recommended book for you.


Table of Contents:


Wordpress Features:

Some of the popular features of Wordpress are:

  • Simple and Flexible
  • Publishing Tools
  • User Management
  • Media Management
  • Themes and Plugins
  • Search Engine Optimized
  • Supports more than 70 languages

Complete list of Wordpress features is available at official website.


Wordpress System Requirements: recommends following system requirements.

  • Database - MySQL 5.6 | MariaDB 10.1 or later
  • Web Server - Apache | Nginx with mod_rewrite module
  • PHP - version 7.3 or later

For complete requirements, you can visit Wordpress documentation.


Environment Specification:

We have configured a CentOS 7 virtual machine with following specifications.

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 2 GB
  • Storage - 20 GB
  • Operating System - CentOS 7.6
  • Hostname -
  • IP Address -


Installing Wordpress Prerequisite - MariaDB 10.3 Server:

Connect with using ssh as root user.

MariaDB 5.x packages are available through standard yum repositories. However, Wordpress requires 10.1 or later. Therefore, we will install MariaDB 10.3 Server on CentOS 7 from MariaDB yum repository.

Install MariaDB yum repository as follows.

[root@wordpress-server-01 ~]# cat >> /etc/yum.repos.d/mariadb.repo << EOF > [mariadb] > name=MariaDB > baseurl= > gpgkey= > gpgcheck=1 > enabled=1 > EOF

Build cache for MariaDB yum repository.

[root@wordpress-server-01 ~]# yum makecache fast Loaded plugins: fastestmirror Determining fastest mirrors * base: * extras: * updates: base | 3.6 kB 00:00 extras | 3.4 kB 00:00 mariadb | 2.9 kB 00:00 updates | 3.4 kB 00:00 (1/3): extras/7/x86_64/primary_db | 205 kB 00:00 (2/3): mariadb/primary_db | 53 kB 00:01 (3/3): updates/7/x86_64/primary_db | 6.4 MB 00:06 Metadata Cache Created

Now, we can install MariaDB 10.3 using yum command.

[root@wordpress-server-01 ~]# yum install -y mariadb-server ... Installed: MariaDB-compat.x86_64 0:10.3.16-1.el7.centos MariaDB-server.x86_64 0:10.3.16-1.el7.centos Dependency Installed: MariaDB-client.x86_64 0:10.3.16-1.el7.centos MariaDB-common.x86_64 0:10.3.16-1.el7.centos boost-program-options.x86_64 0:1.53.0-27.el7 galera.x86_64 0:25.3.26-1.rhel7.el7.centos lsof.x86_64 0:4.87-6.el7 perl.x86_64 4:5.16.3-294.el7_6 perl-Carp.noarch 0:1.26-244.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 perl-Pod-Escapes.noarch 1:1.04-294.el7_6 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-294.el7_6 perl-macros.x86_64 4:5.16.3-294.el7_6 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 rsync.x86_64 0:3.1.2-6.el7_6.1 Replaced: mariadb-libs.x86_64 1:5.5.60-1.el7_5 Complete!

MariaDB service is already enabled by the Installer, therefore, we are only required to start MariaDB Service.

[root@wordpress-server-01 ~]# systemctl start mariadb.service

Configure MariaDB server instance.

[root@wordpress-server-01 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

MariaDB 10.3 server has been installed and configured on CentOS 7.


Installing Wordpress Prerequisite - Apache 2.4 HTTP Server:

Apache 2.4 HTTP Server is available in base yum repository, therefore, we can install it easily with yum command.

[root@wordpress-server-01 ~]# yum install -y httpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: * extras: * updates: Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-89.el7.centos will be installed --> Processing Dependency: httpd-tools = 2.4.6-89.el7.centos for package: httpd-2.4.6-89.el7.centos.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-89.el7.centos.x86_64 --> Processing Dependency: for package: httpd-2.4.6-89.el7.centos.x86_64 --> Processing Dependency: for package: httpd-2.4.6-89.el7.centos.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-89.el7.centos will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.6-89.el7.centos updates 2.7 M Installing for dependencies: apr x86_64 1.4.8-3.el7_4.1 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-89.el7.centos updates 90 k mailcap noarch 2.1.41-2.el7 base 31 k Transaction Summary ================================================================================ Install 1 Package (+4 Dependent packages) Total download size: 3.0 M Installed size: 10 M Downloading packages: (1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00 (2/5): httpd-tools-2.4.6-89.el7.centos.x86_64.rpm | 90 kB 00:00 (3/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00 (4/5): httpd-2.4.6-89.el7.centos.x86_64.rpm | 2.7 MB 00:04 (5/5): apr-1.4.8-3.el7_4.1.x86_64.rpm | 103 kB 00:04 -------------------------------------------------------------------------------- Total 699 kB/s | 3.0 MB 00:04 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.4.8-3.el7_4.1.x86_64 1/5 Installing : apr-util-1.5.2-6.el7.x86_64 2/5 Installing : httpd-tools-2.4.6-89.el7.centos.x86_64 3/5 Installing : mailcap-2.1.41-2.el7.noarch 4/5 Installing : httpd-2.4.6-89.el7.centos.x86_64 5/5 Verifying : httpd-tools-2.4.6-89.el7.centos.x86_64 1/5 Verifying : mailcap-2.1.41-2.el7.noarch 2/5 Verifying : httpd-2.4.6-89.el7.centos.x86_64 3/5 Verifying : apr-1.4.8-3.el7_4.1.x86_64 4/5 Verifying : apr-util-1.5.2-6.el7.x86_64 5/5 Installed: httpd.x86_64 0:2.4.6-89.el7.centos Dependency Installed: apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-89.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete!

Enable and start httpd.service.

[root@wordpress-server-01 ~]# systemctl enable httpd.service Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/httpd.service. [root@wordpress-server-01 ~]# systemctl start httpd.service

Allow HTTP service in Linux firewall.

[root@wordpress-server-01 ~]# firewall-cmd --permanent --add-service=http success [root@wordpress-server-01 ~]# firewall-cmd --reload success

Apache 2.4 HTTP Server has been installed on CentOS 7.


Installing Wordpress Prerequisite - PHP 7.4:

Wordpress requires PHP 7.4 or later, which is not available in standard yum repositories.

Therefore, we are installing Remi, a third party yum repository, to install latest version of PHP on CentOS 7.

But, first we are installing EPEL (Extra Packages for Enterprise Linux) because Remi repository is depend on EPEL yum repository.

[root@wordpress-server-01 ~]# yum install -y epel-release Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: * extras: * updates: Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-11 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: epel-release noarch 7-11 extras 15 k Transaction Summary ================================================================================ Install 1 Package Total download size: 15 k Installed size: 24 k Downloading packages: epel-release-7-11.noarch.rpm | 15 kB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-11.noarch 1/1 Verifying : epel-release-7-11.noarch 1/1 Installed: epel-release.noarch 0:7-11 Complete!

Install Remi yum repository using rpm command.

[root@wordpress-server-01 ~]# rpm -ivh Retrieving warning: /var/tmp/rpm-tmp.D7RUDj: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY Preparing... ################################# [100%] Updating / installing... 1:remi-release-7.6-2.el7.remi ################################# [100%]

Build cache for Remi yum repository.

[root@wordpress-server-01 ~]# yum makecache fast Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile epel/x86_64/metalink | 8.0 kB 00:00 * base: * epel: * extras: * remi-safe: * updates: base | 3.6 kB 00:00 extras | 3.4 kB 00:00 mariadb | 2.9 kB 00:00 remi-safe | 3.0 kB 00:00 updates | 3.4 kB 00:00 remi-safe/primary_db | 1.6 MB 00:06 Metadata Cache Created

Install PHP 7.4 and relevant packages from Remi yum repository.

[root@wordpress-server-01 ~]# yum install -y php74-php php74-php-common php74-php-opcache php74-php-mcrypt php74-php-cli php74-php-gd php74-php-curl php74-php-mysqlnd ... Installed: php74-php.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-cli.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-common.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-gd.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-mysqlnd.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-opcache.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-pecl-mcrypt.x86_64 0:1.0.2-2.el7.remi Dependency Installed: audit-libs-python.x86_64 0:2.8.4-4.el7 checkpolicy.x86_64 0:2.5-8.el7 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 environment-modules.x86_64 0:3.2.10-10.el7 fontconfig.x86_64 0:2.13.0-4.3.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 gd-last.x86_64 0:2.2.5-8.el7.remi jbigkit-libs.x86_64 0:2.0-11.el7 libX11.x86_64 0:1.6.5-2.el7 libX11-common.noarch 0:1.6.5-2.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXpm.x86_64 0:3.5.12-1.el7 libargon2.x86_64 0:20161029-3.el7 libcgroup.x86_64 0:0.41-20.el7 libjpeg-turbo.x86_64 0:1.2.90-6.el7 libmcrypt.x86_64 0:2.5.8-13.el7 libsemanage-python.x86_64 0:2.5-14.el7 libtiff.x86_64 0:4.0.3-27.el7_3 libwebp7.x86_64 0:1.0.2-1.el7.remi libxcb.x86_64 0:1.13-1.el7 php74-php-json.x86_64 0:7.4.0~alpha2-11.el7.remi php74-php-pdo.x86_64 0:7.4.0~alpha2-11.el7.remi php74-runtime.x86_64 0:1.0-1.el7.remi policycoreutils-python.x86_64 0:2.5-29.el7_6.1 python-IPy.noarch 0:0.75-6.el7 scl-utils.x86_64 0:20130529-19.el7 setools-libs.x86_64 0:3.3.8-4.el7 tcl.x86_64 1:8.5.13-8.el7 Dependency Updated: policycoreutils.x86_64 0:2.5-29.el7_6.1 Complete!

Verify PHP 7.4 installation by checking its version.

[root@wordpress-server-01 ~]# php74 -v PHP 7.4.0alpha2 (cli) (built: Jun 25 2019 09:01:47) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies with Zend OPcache v7.4.0alpha2, Copyright (c), by Zend Technologies

Restart httpd.service to apply changes.

[root@wordpress-server-01 ~]# systemctl restart httpd.service

PHP 7.4 and relevant packages have been installed on CentOS 7 server.


Configuring Wordpress Prerequisite - Create a MariaDB Database and User:

Connect to MariaDB database instance using mysql command as root user.

[root@wordpress-server-01 ~]# mysql -u root -p123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.3.16-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>

Create a database as required by Wordpress.

MariaDB [(none)]> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; Query OK, 1 row affected (0.036 sec)

Create a user with complete privileges on wordpress database.

MariaDB [(none)]> GRANT ALL ON wordpress.* TO 'wpuser'@'localhost' IDENTIFIED BY '123'; Query OK, 0 rows affected (0.003 sec)

Reload privileges tables and exit.

MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.001 sec) MariaDB [(none)]> exit Bye


Installing Wordpress 5 on CentOS 7 LAMP server:

Currently, Wordpress 5.2.2 is available to download on Wordpress Download Page.

But, you can always download the latest release of Wordpress using the link in following command.

[root@wordpress-server-01 ~]# cd /tmp [root@wordpress-server-01 tmp]# wget --2019-06-26 07:12:35-- Resolving ( Connecting to (||:443... connected. HTTP request sent, awaiting response... 200 OK Length: 11200591 (11M) [application/octet-stream] Saving to: âlatest.tar.gz.2â 100%[======================================>] 11,200,591 1.00MB/s in 66s 2019-06-26 07:13:42 (165 KB/s) - âlatest.tar.gz.2â saved [11200591/11200591]

Extract download file to Apache document root directory.

[root@wordpress-server-01 tmp]# tar xvf latest.tar.gz -C /var/www/html/ ... wordpress/wp-admin/options-permalink.php wordpress/wp-admin/widgets.php wordpress/wp-admin/setup-config.php wordpress/wp-admin/install.php wordpress/wp-admin/admin-header.php wordpress/wp-admin/post-new.php wordpress/wp-admin/themes.php wordpress/wp-admin/options-reading.php wordpress/wp-trackback.php wordpress/wp-comments-post.php

Create the configuration file for Wordpress as follows.

[root@wordpress-server-01 ~]# touch /var/www/html/wordpress/wp-config.php

Adjust file permissions and SELinux file contexts.

[root@wordpress-server-01 ~]# chown -R apache:apache /var/www/html/wordpress/ [root@wordpress-server-01 ~]# restorecon -R /var/www/html/wordpress/

Temporarily put SELinux in permissive mode, so the Wordpress Installer can write on wp-config.php file.

[root@wordpress-server-01 ~]# setenforce 0

Browse URL from a client's browser.


Select your preferred Language and click on Continue.


Read the instructions and click on Let's go!.


Provides database connection details like database name and user, that we have created in previous section.

Click on Submit.


Click on Run the installation.


Provide details about your site in this page.

Click on Install Wordpress.


Wordpress has been installed.

Click on Log in to go to Login Page.


Login as Ahmer Mansoor user.


We are reached at the dashboard of Wordpress.

We can visit our Wordpress site by accessing the URL from a client's browser.


Put back SELinux in enforcing mode.

[root@wordpress-server-01 ~]# setenforce 1

We have successfully installed Wordpress 5 on CentOS 7 LAMP server.