Wordpress (Wordpress.org) 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
- Wordpress System Requirements
- Environment Specification
- Installing MariaDB 10.3 Server
- Installing Apache 2.4 HTTP Server
- Installing PHP 7.4
- Create a MariaDB Database and User
- Installing Wordpress on CentOS 7 LAMP server
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 Wordpress.org official website.
Wordpress System Requirements:
Wordpress.org 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 - wordpress-server-01.example.com
- IP Address - 192.168.116.181/24
Installing MariaDB 10.3 Server:
Connect with wordpress-server-01.example.com 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.
# cat >> /etc/yum.repos.d/mariadb.repo << EOF > [mariadb] > name=MariaDB > baseurl=http://yum.mariadb.org/10.3/centos7-amd64 > gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB > gpgcheck=1 > enabled=1 > EOF
Build cache for MariaDB yum repository.
# yum makecache fast
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.ges.net.pk
* extras: mirrors.ges.net.pk
* updates: mirrors.ges.net.pk
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.
# yum install -y mariadb-server
MariaDB service is already enabled by the Installer, therefore, we are only required to start MariaDB Service.
# systemctl start mariadb.service
Configure MariaDB server instance.
# 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 database has been installed and configured on Linux server.
Installing 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.
# yum install -y httpd
Enable and start httpd.service.
# systemctl enable httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. # systemctl start httpd.service
Allow HTTP service in Linux firewall.
# firewall-cmd --permanent --add-service=http success # firewall-cmd --reload success
Apache 2.4 HTTP Server has been installed on CentOS 7.
Installing 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.
# yum install -y epel-release
Install Remi yum repository using rpm command.
# rpm -ivh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Retrieving http://rpms.remirepo.net/enterprise/remi-release-7.rpm
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.
# yum makecache fast
Install PHP 7.4 and relevant packages from Remi yum repository.
# 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
Verify PHP 7.4 installation by checking its version.
# 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.
# systemctl restart httpd.service
PHP 7.4 and relevant packages have been installed on CentOS 7 server.
Create a MariaDB Database and User:
Connect to MariaDB database instance using mysql command as root user.
# 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 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.
# cd /tmp # wget https://wordpress.org/latest.tar.gz --2019-06-26 07:12:35-- https://wordpress.org/latest.tar.gz Resolving wordpress.org (wordpress.org)... 198.143.164.252 Connecting to wordpress.org (wordpress.org)|198.143.164.252|: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.
# tar xf latest.tar.gz -C /var/www/html/
Create the configuration file for Wordpress as follows.
# touch /var/www/html/wordpress/wp-config.php
Adjust file permissions and SELinux file contexts.
# chown -R apache:apache /var/www/html/wordpress/ # restorecon -R /var/www/html/wordpress/
Temporarily put SELinux in permissive mode, so the Wordpress Installer can write on wp-config.php file.
# setenforce 0
Browse URL http://wordpress-server-01.example.com/wordpress/ 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 user.
We are reached at the dashboard of Wordpress.
We can visit our Wordpress site by accessing the URL http://wordpress-server-01.example.com/wordpress from a client's browser.
Put back SELinux in enforcing mode.
# setenforce 1
We have successfully installed Wordpress 5 on CentOS 7 LAMP server.