How To Install WordPress On Centos 7

Published: October 29, 2017 (Updated: Oct 29, 2017)

Enjoying this content? Subscribe to the Channel!

The Ultimate Guide: Installing WordPress on CentOS 7 (LAMP Setup)


Welcome to Darren’s Tech Tutorials!

Ready to launch your own powerful, self-hosted website? Installing WordPress—the world’s most popular content management system—on your CentOS 7 server might seem complex, but with the right steps, it’s a straightforward process.

This guide walks you through the essential commands and configurations needed to get WordPress up and running smoothly on your existing CentOS 7 LAMP (Linux, Apache, MariaDB, PHP) stack. Let’s turn that powerful server into a dynamic publishing platform!


Prerequisites (Before We Begin)

This tutorial assumes you already have a fully configured server environment. If you need help setting up the foundational layers, please pause here and complete these steps:

  • CentOS 7 Installed: Your core operating system must be ready.
  • Apache (HTTPD) Installed and Running: This is your web server.
  • MariaDB (or MySQL) Installed: This is your database server.
  • PHP and Required Extensions Installed: WordPress relies heavily on PHP. Ensure extensions like php-mysql, php-gd, and php-xml are installed.

If you are missing any of these crucial components, check the linked tutorials from the video description to get caught up!


Step 1: Downloading and Extracting WordPress

The first step is grabbing the latest WordPress files and placing them into the correct directory where Apache can serve them.

1. Navigate to the Web Root and Download

We will use the wget command to download the compressed WordPress files directly from the official repository into the standard web root directory, /var/www/html/.

cd /var/www/html/
wget https://wordpress.org/latest.tar.gz

2. Extract the Files

Now, uncompress the archive. This will create a directory named wordpress inside your web root.

tar -xzvf latest.tar.gz

Once extracted, you can safely remove the compressed file to save space:

rm latest.tar.gz

Step 2: Setting Up the MariaDB Database

WordPress requires a dedicated database, a unique user, and specific permissions to store all your posts, settings, and user data.

1. Log into MariaDB

Access the MariaDB shell as the root user:

mysql -u root -p

(You will be prompted to enter the MariaDB root password.)

2. Create the Database

We will name the database wordpressdb.

CREATE DATABASE wordpressdb;

3. Create a Dedicated Database User

For security, never use the root user for applications. We’ll create a dedicated user named wpuser and assign a strong password (replace 'YOUR_STRONG_PASSWORD' below):

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'YOUR_STRONG_PASSWORD';

4. Grant Permissions

Give the new wpuser full permissions only on the wordpressdb database:

GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost';

5. Flush and Exit

Apply the changes and exit the MariaDB prompt:

FLUSH PRIVILEGES;
EXIT;

Step 3: Configuring WordPress Files and Permissions

On CentOS 7, security policies (like SELinux) and strict file ownership are vital. We must ensure the Apache web server (which runs as the apache user) has the proper permissions to read, write, and modify the WordPress files.

1. Change Directory Ownership

We must change the ownership of the entire WordPress directory to the apache user and group.

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

2. Set File Permissions

Set the permissions to ensure security while allowing the web server to function:

chmod -R 755 /var/www/html/wordpress

3. Configure wp-config.php

WordPress uses a configuration file to connect to the database. Navigate into the WordPress directory and copy the sample configuration file:

cd /var/www/html/wordpress
cp wp-config-sample.php wp-config.php

Now, open wp-config.php using your preferred text editor (like nano or vi):

vi wp-config.php

Find the following database definitions and update them with the details you created in Step 2:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' ); 

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

/** MySQL database password */
define( 'DB_PASSWORD', 'YOUR_STRONG_PASSWORD' ); 

/** MySQL hostname */
define( 'DB_HOST', 'localhost' ); 

Pro Tip: While you are in the configuration file, scroll down and update the unique security keys and salts. This is a critical security step!


Step 4: Finalizing the Installation via Web Browser

The hard work is done! Your server is configured, the database is ready, and the files are in place. All that’s left is running the final web-based setup.

1. Access the WordPress Installer

Open your web browser and navigate to the IP address or domain name of your CentOS 7 server, followed by the /wordpress directory:

http://[YOUR_SERVER_IP]/wordpress

2. Follow the 5-Minute Setup

You should be greeted by the WordPress welcome screen.

  1. Select your language.
  2. Provide a Site Title (you can change this later).
  3. Create a secure Username and Password for your administrative account.
  4. Enter your email address.
  5. Click Install WordPress.

Congratulations! You have successfully installed WordPress on your robust CentOS 7 environment. You can now log into your administration dashboard and begin building your website!


Conclusion: Time to Start Blogging!

That’s how you take control of your digital presence by installing WordPress directly on your powerful CentOS 7 server. You now have a high-performance, self-hosted platform ready for development, blogging, or e-commerce.

We hope this detailed, step-by-step guide from Darren’s Tech Tutorials helped you conquer the installation process!

Did you find this tutorial helpful? Hit that like button, subscribe to Darren’s Tech Tutorials for more expert guides, and let us know in the comments what you plan to build with your new WordPress site! Happy coding!