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.


  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  [On CentOS/RHEL 7]
# dnf install        [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 ##

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

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

## FLUSH privileges ##

## Exit ##

Preparing WordPress Installation

Now we are ready to download the latest WordPress archive:

# cd /tmp && wget

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:


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
  ErrorLog /var/log/httpd/tecminttest-error-log
  CustomLog /var/log/httpd/tecminttest-acces-log common

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.


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 liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

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.

51 thoughts on “Install WordPress 5 with Apache, MariaDB 10 and PHP 7 on CentOS 7”

  1. Followed each step, but then WordPress has no permission to edit files, like editing the htaccess, or updating, etc.

    I tried some suggestions I found over the internet, either a plugin (All in one WordPress security) but still can’t make it work.

    Any idea?

  2. Hi Ravi, Thank you for the manual. It is very comprehensive and useful. Can you extend a little bit the instructions to cover the ssl. It should be good if you show a way to protect the wp-admin with ssl

  3. Couldn’t install plugins, ended up granting apache ownership to wordpress directory. That did fix the issue but I’m uncertain of security implications.

    Also needed PHP7 because of some plugin so ended up redoing installation with the following:

    # yum install epel-release yum-utils
    # yum install
    # yum-config-manager --enable remi-php72
  4. For RHEL 7, step one is missing this command that must be executed BEFORE ‘mysql_secure_installation:’

    # systemctl start mariadb && systemctl enable mariadb

    Otherwise, the following error is encountered:

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

  5. I see many error in error log

    017/03/31 18:06:16 [crit] 19398#0: *1220 connect() to unix:/tmp/php_fpm.sock failed (2: No such file or directory) while connecting to upstream, client:, server:, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php_fpm.sock:", host: ""

    • – login page -> ok
      after login, there is not graphics /images. only text are shown. Hard to manage the wordpress. Kindly help me to resolve this problem

  6. Hellpo there! Thiss is my 1st comment here so I just wanted
    to give a quick shout out and tell you I really enjoy reading through your articles.
    Cann you recommend anny otyher blogs/websites/forums that deazl with the same subjects?
    Thanks for your time!


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.