Install WordPress 5 with Apache, MariaDB 10 and PHP 7 on CentOS 7

WordPress is an open source and free blogging application and a dynamic CMS (Content Management System) developed using MySQL and PHP. It has huge number of third party plugins and themes. WordPress currently one of the most popular blogging platform available on the internet and used by millions of people across the globe.

In this tutorial we are going to explain how to install the popular content management system – WordPress using LAMP (Linux, Apache, MySQL/MariaDB, PHP) on RHEL, CentOS and Fedora Linux distributions.

Requirements

  1. A dedicated server or a VPS (Virtual Private Server) with CentOS 7 minimal installation.

IMPORTANT: I suggest you to go for Bluehost Hosting, which offers us a special discount for our readers, and it also comes with a 1 Free Domain, 1 IP address, Free SSL and 24/7 support for life.

Installing Remi Repository on CentOS 7

The installation that we will perform will be on CentOS 7, but same instructions also works on RHEL and Fedora distributions as well.

First install and enable Remi repository using following command.

# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm  [On CentOS/RHEL 7]
# dnf install http://rpms.remirepo.net/fedora/remi-release-29.rpm        [On Fedora 29]

Since we are going to use php7.3, we will need to disable the installation of php5.4 using yum-config-manager command provided by yum-utils tool.

# yum install yum-utils
# yum-config-manager --disable remi-php54
# yum-config-manager --enable remi-php73

Installing LAMP Stack on CentOS 7

Now we are ready to install all the required packages related to our LAMP stack using following command.

# yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt

Now that the installation is complete, we will need to start and secure our MariaDB installation.

# systemctl start mariadb
# mysql_secure_installation

Follow the instructions on the screen to answer the questions related to your MariaDB server security.

Then we will configure MariaDB to start automatically on system boot:

# systemctl enable mariadb

Next we will do the same for Apache web server:

# systemctl start httpd
# systemctl enable httpd

Creating WordPress MySQL Database

Our WordPress will require a database and a database user. To create one, simply use the following commands. Feel free to replace the database name, user and password as per your preferences:

# mysql -u root -p
Enter password:

## Create database ##
CREATE DATABASE wordpress;

## Creating new user ##
CREATE USER [email protected] IDENTIFIED BY "secure_password";

## Grant privileges to database ##
GRANT ALL ON wordpress.* TO [email protected];

## FLUSH privileges ##
FLUSH PRIVILEGES;

## Exit ##
exit

Preparing WordPress Installation

Now we are ready to download the latest WordPress archive:

# cd /tmp && wget http://wordpress.org/latest.tar.gz

Next extract the archive in our web directory:

# tar -xvzf latest.tar.gz -C /var/www/html

The above will create the following directory, which will contain our WordPress script:

/var/www/html/wordpress

Now change the ownership of that directory to user “apache”:

# chown -R apache /var/www/html/wordpress

Creating Apache Virtual Host for WordPress

We will create a separate virtual host for our WordPress install. Open /etc/httpd/conf/httpd.conf with your favorite text editor:

# vim /etc/httpd/conf/httpd.conf

And add the following code at the bottom of the file and replace the marked text with the information related to your installation:

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html/wordpress
  ServerName tecminttest.com
  ServerAlias www.tecminttest.com
  ErrorLog /var/log/httpd/tecminttest-error-log
  CustomLog /var/log/httpd/tecminttest-acces-log common
</VirtualHost>

Save your changes and restart Apache:

# systemctl restart httpd

Installing WordPress on Website

Now we are ready to run our WordPress installation. To start the installation you can access either your server’s IP address at http://ip-address or if installing locally you can use http://localhost or if you are using a real domain, you can use the domain instead. You should see the following page:

Setup WordPress on CentOS 7

Setup WordPress on CentOS 7

When you click on Let’s Go button, you will be redirected to the next page of the installation, where you will have to enter the database details we created earlier.

WordPress Database Settings

WordPress Database Settings

When you have enter the details, click the submit button. WordPress will attempt to create it’s configuration file called wp-config.php. If everything is fine you should see the following page:

WordPress Installation Setup

WordPress Installation Setup

Once you click the “Run the installation” button, you will be asked to enter some details about your website: Site Title, Username, Password and Email address.

WordPress Website Details

WordPress Website Details

When you have filled all the required information finalize the installation by clicking the button at the bottom. Your installation is now complete. Your front page should look something the image below:

WordPress Website View

WordPress Website View

And the WordPress dashboard looks as follows:

WordPress Admin Dashboard

WordPress Admin Dashboard

You can now start managing your WordPress website.

Conclusion

You have successfully completed the installation of WordPress using LAMP on CentOS 7. If you had any difficulties or questions, please submit them in the comment section below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

46 Responses

  1. Adam says:

    I know it’s in there somewhere, but I have no idea how to access my wordpress installation. I can’t FTP yet for some reason and I am too dumb to know how to get that to work. I may have to throw in the towel on this.

  2. Ravi Saive says:

    @ Adam,

    You have used wrong (comma) in the following line. that’s the reason you getting syntax error.

    define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

    Use this following line with proper commas used. it will work..

    define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

    • Adam says:

      @Ravi Slaive

      Thank you for your help, but inputting the correct commas (Is saw the slight difference) still did not work. I input this:

      define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

      Still get this:

      -bash: syntax error near unexpected token `’DB_NAME’,’

      • Ravi Saive says:

        The error itself telling that you have used wrong commas

        `’DB_NAME’,’

        it should be ’DB_NAME’,

        Why not you copy my whole configuration of Step5 and then modify it.

        • Adam says:

          Forgive me for my ridiculous amount of n00bness on this. But what comma is there other than the one next to the enter key? I’m on a Mac in the default Terminal app if that helps. All I see is this one:

          All Terminal will do is this one:

          But I copy and pasted your edits and still get errors:

          define(’DB_NAME’, ’MY_DATA_BASE_NAME’);
          -bash: syntax error near unexpected token `’DB_NAME’,’

  3. Adam says:

    I am on a LEMP install. I followed your LEMP install to a T on my CentOS server. I am literally stuck on the very last step before going into wordpress. When I type this in:

    define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

    I get the following error:

    -bash: syntax error near unexpected token `’DB_NAME’,’

    I am a n00b, and a frustrated one.

  4. Josh Maggart says:

    Great article! Thanks so much for sharing. However I am receiving a 404 error when browsing to mydomain.tv/wordpress. I added the 127.0.0.1 wordpress to /etc/hosts and it’s still no good. I had been following this tutorial, http://www.howtoforge.com/perfect-server-centos-6.2-x86_64-with-nginx-ispconfig-3 to install the server and had to stop before installing courier imap, so I thought I would install WordPress. Hopefully someone can give me pointers on what I may have missed. Thanks!

  5. Sreekanth says:

    It is very good article I have followed the same steps to configure wordpress in Fedora 17 with nginx. But it is not working for me . Couldn’t resolve the name wordpress when I am trying to access it via browser. Please help

    • Ravi Saive says:

      @Sreekanth

      To resolve hostname just add the following line to your /etc/hosts file.

      127.0.0.1 wordpress

      and try browsing again. it should work on all browsers. if it doesn’t work you need to look into other things.

  6. Great artical, I unfortunately had some problems printing this artcle out, The print formating looks a little screwed over, something you might want to look into.

    • Ravi Saive says:

      Dear Chaussures.

      Thanks for point out we will work on this soon and give a option to print and view pdf option..

  7. seo prices says:

    great read, I’ll be sharing the information

  8. Sell Cisco says:

    Nice post. I used to be checking continuously this blog and I am impressed! Extremely helpful information particularly the last section :) I care for such info much. I was seeking this particular information for a long time. Thanks and good luck.

  9. Hello, i believe that i noticed you visited my blog thus i came to return the favor?.I’m trying to to find issues to enhance my site!I suppose its good enough to use some of your ideas!!

  10. I am no longer positive where you’re getting your information, however good topic. I must spend a while finding out much more or working out more. Thanks for fantastic information I was in search of this info for my mission.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.