This brief tutorial is going to show you how to install WordPress on top of a CentOS 7 server.  If you haven’t installed or used CentOS 7, then brace yourself for some of the changes.

Some of the commands that you’re used to in previous versions of CentOS are gone, replaced with newer ones. For example, iptables commands that used to work in previous version of CentOS don’t work in version 7.

The iptables commands are now replaced with firewall-cmd. That’s just one of the many changes included in the new CentOS 7.

Installing and configuring WordPress may also be challenging for some new users. This post which is geared towards new users should come in handy when installing WordPress on CentOS 7.

If you don’t already know, WordPress depends on a web server, database server, and PHP modules and scripts. Without these servers and scripts, WordPress will not be able to compile and run.

For this tutorial, will be installing Apache web server, MariaDB database server, PHP5 and other PHP5 modules.


  • Installing Apache2 web server in CentOS 7

Since WordPress depends on  a web server, let’s get started by installing Apache2 web server in CentOS 7. To do that , run the commands below.

sudo yum -y install httpd

It’s always good to automatically start up Apache2 when your server reboots so that services can be available. To enable Apache2 to automatically start up when you reboot your server, run the commands below.

sudo systemctl enable httpd.service

To manually stat Apache2, run the commands below.

sudo systemctl start httpd.service


  • Installing MariaDB database server

The next server WordPress depends on is a database server. For this post, we’re going to install MariaDB database server.  To do that run the commands below.

sudo yum -y install mariadb-server mariadb

Again, you want to enable the database server to automatically start up when you reboot your computer. To enable the database server to start up automatically, run the commands below.

sudo systemctl enable mariadb.service

To manually start MariaDB database server, run the commands below.

sudo systemctl start mariadb.service

The next step is to secure the database server and create a root password. To do that, run the commands below.


Next, follow the guide below to answer the prompts until you’re done.

  • Enter current password for root (enter for none): press Enter
  • Set root password? Y
    • New password: Type new root password
    • Re-enter new password: Confirm the password
  • Remove anonymous users? Y
  • Disallow root login remotely? Y
  • Remove test database and access to it? Y
  • Reload privilege tables now? Y

Next, create a database to host WordPress content. To create WordPress database run the commands below to logon to MariaDB database server.

mysql -u root -p

Then run the commands below to create a new database called wpdatabase.


Then run the commands below to create a WordPress database user called wpuser with password.

CREATE USER wpuser@localhost IDENTIFIED BY 'user_password_here';

Finally, great the new user rights and privileges to manage the newly created database.

GRANT ALL PRIVILEGES ON wpdatabase.* TO wpuser@localhost;

Flush and exit.



  • Installing PHP5 and its modules in CentOS 7

Finally, install PHP5 and its modules for WordPress to run. Without PHP, WordPress won’t compile and run. To enable it run the commands below.

sudo yum -y install php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mysql

Restart Apache2 and enable PHP5 modules.

sudo systemctl start httpd.service


  • After that, go and download WordPress content from online and extract it.. then copy it over to Apache2 default root directory.

    WordPress content can be downloaded using the commands below.

    cd /tmp/ && wget

    Next, extract the content and copy it to the /var/www/html directory.

    sudo cp -rf wordpress/* /var/www/html/

    Next, change the permissions and ownership of the WordPress content folders.

    chown -R apache:apache /var/www/html
    chmod -R 755 /var/www/html

    Next, create a copy of wp-config-sample.php and neame it wp-config.php.

    sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

    Then edit the wp-config.php file and enter the database name, database username and user password you created earlier.

    vi /var/www/html/wp-config.php

    // ** MySQL settings – You can get this info from your web host ** //

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘wpdatabase‘);

    /** MySQL database username */
    define(‘DB_USER’, ‘wpuser‘);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘databse user password‘);

    Save the file.

    Finally, enable HTTP traffic through the firewall.

    firewall-cmd --permanent --zone=public --add-service=http
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --reload

    Restart Apache2, then open your browser and browse to your server. You should see WordPress configuration page.


Wordpress setup page