How to Install WordPress with Apache on CentOS 7

Updated on

4 min read

Install WordPress with Apache on CentOS 7

WordPress is the most popular open-source blogging and CMS platform worldwide, powering a quarter of all websites on the Internet today. It is based on PHP and MySQL and packs a ton of features that can be extended with free and premium plugins and themes. WordPress is the simplest way to create your online store, website, or blog.

In this tutorial, we will explain how to install WordPress on CentOS 7. At the time of writing this article, the latest version of WordPress is version 5.0.3.

We’ll be using a LAMP stack with Apache as a web server, SSL certificate, the latest PHP 7.2 and MySQL/MariaDB as a database server.


Ensure the following prerequisites are met before continuing with this tutorial:

Creating MySQL Database

WordPress stores its data and configuration in a MySQL database. If you already don’t have MySQL or MariaDB installed on your CentOS server you can install by following one of the guides below:

Login to the MySQL shell by executing the following command:

mysql -u root -p

From within the MySQL shell, run the following SQL statement to create a new database named wordpress:

CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Next, create a MySQL user account named wordpressuser and grant the necessary permissions to the user by running the following command:

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

Once done, exit the mysql console by typing:


Downloading Wordpress

The following command will download the latest version of WordPress from the WordPress download page with wget and extract the archive to the domain’s document root directory:

wget -q -O - "" | sudo tar -xzf - -C /var/www/html --transform s/wordpress/

Set the correct permissions so that the web server can have full access to the site’s files and directories:

sudo chown -R apache: /var/www/html/

Configuring Apache

By now, you should already have Apache with SSL certificate installed on your system, if not check the prerequisites for this tutorial.

Open your text editor and edit the domain’s Apache virtual hosts configuration :

sudo nano /etc/httpd/conf.d/

Don’t forget to replace with your Wordpress domain and set the correct path to the SSL certificate files.

<VirtualHost *:80>

  Redirect permanent /

<VirtualHost *:443>

  <If "%{HTTP_HOST} == ''">
    Redirect permanent /

  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/

  ErrorLog /var/log/httpd/
  CustomLog /var/log/httpd/ combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/
  SSLCertificateKeyFile /etc/letsencrypt/live/
  SSLCertificateChainFile /etc/letsencrypt/live/

  <Directory /var/www/html/>
      Options FollowSymLinks
      AllowOverride All
      Require all granted


The configuration will tell Apache to redirects HTTP to HTTPS and www to non-www version of your domain.

Restart the Apache service for the changes to take effect:

sudo systemctl restart httpd

Completing the WordPress Installation

Now that Wordpress is downloaded and the Apache server is configured, you can finish the installation through the web interface.

Open your browser, type your domain and a screen similar to the following will appear:

Install wordpress language selector

Select the language you would like to use and click on the Continue button.

Next, you will see the following information page, click on the Let's go! button.

Install wordpress information

On the next screen, the setup wizard will ask you to enter your database connection details. Enter the MySQL user and database details you previously created.

Install wordpress database information

Start the WordPress installation by clicking on the Run the Installation button.

Install wordpress Run Installation

In the next step, you’ll need to enter a name for your WordPress site and choose a username (for security purposes do not use “admin” ).

The installer will automatically generate a strong password for you. Do not forget to save this password. You can also set the password by yourself.

Enter your email address and select whether you want to discourage search engines from indexing the site (not recommended).

Install wordpress welcome

Click Install WordPress and once the installation is completed you will be taken to a page informing you that WordPress has been installed.

To access your WordPress login page click on the Log in button.

Install wordpress completed

Enter your username and password.

wordpress login form

You will be redirected to the WordPress administration dashboard.

wordpress dashboard

From here, you can start customizing your WordPress installation by installing new themes and plugins.


Congratulations, you have successfully installed WordPress with Apache on your CentOS 7 server. First Steps With WordPress is a good starting place to learn more about how to get started with WordPress.

If you have questions, feel free to leave a comment below.