Install WordPress with Apache on CentOS 7.

How To Install WordPress With Apache On CentOS 7.

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.

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.


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:

  • Install MySQL on CentOS 7 .

  • Install MariaDB on CentOS 7 .

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.

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).

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.

Enter your username and password.

You will be redirected to the WordPress administration 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.