How to Install Wordpress on CentOS7


WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database. WordPress is used by more than 40.5% of the top 10 million websites as of March 2021, WordPress is one of the most popular blog-publishing and content management system solutions in use.


  • You have already deploy a Cybree Instance with CentOS 7 image.
  • You have already completed the "How to install LAMP on Centos 7 tutorial”, and installed LAMP (Linux, Apache, MySQL, PHP) on your server
  • You have your root mysql password so you can log into mysql as root.

Step 1: Create a Database

  1. After you login to your Cybree instance, run the following command to log in as root user
mysql -u root -p
  1. You will be prompted for the password you set earlier as root when you installed MySQL. If you do not have your root password, you will have to reset it.

  2. Once logged in, we can create a database with the following command. You can call it whatever you would like, but for this article, we are calling it WordPress. Please note that every mysql command will require a ; (colon) at the end of every statement

  1. Once our database is created, you need to create a user for that database. Once again I am using a very simple username, and password so feel free to make yours more secure. Do remember your username and password as we will need it later in this article. Type the following command.
CREATE USER adminuser@localhost IDENTIFIED BY 'password';
  1. Now we need to give that user permissions to access the database. We can add those permissions with the following command. If you use your own database name, user, and password, you should also replace it in the command. Also note that the password is contained in single quotes followed by a colon;
GRANT ALL PRIVILEGES ON wordpress.* TO adminuser@localhost IDENTIFIED BY 'password';
  1. Now we want to flush MySQL so that it is made aware of those changes.
  1. and finally, exit MySQL

Step 2) Install WordPress

  1. Download the latest wordpress file
cd ~ 

  1. Now, let’s  unzip that tar file
tar -xzvf latest.tar.gz
  1. That should create a file named WordPress in our home directory. Next, we want to move that file and its contents to our public_html folder, so it can serve up the content for our website. We want to keep the same file permission, so we use the following rsync command.
sudo rsync -avP ~/wordpress/ /var/www/html/
  1. For WordPress to be able to upload files, we need to create an uploads directory. Go ahead and use the following:
mkdir /var/www/html/wp-content/uploads
  1. Lastly, update the Apache permissions for new WordPress files
sudo chown -R apache:apache /var/www/html/*

Step 4) Configuring WordPress

  1. Next, we have to update the wp-config.php file in WordPress for it to connect to the database successfully. So let’s go to the html folder where your WordPress install is located.
cd /var/www/html
  1. Create a wp-config.php file by copying the sample file WordPress has provided.
cp wp-config-sample.php wp-config.php
  1. Now, we need to edit the new wp-config.php file with the correct database information we created in Step 1.  I used vim to make that change, but you can use any editor you are comfortable with.
sudo nano wp-config.php
  1. Next, we need to add info into the following fields of the database, user, and password we created in Step 1.

Old Settings:

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

/** The name of the database for WordPress */ 
define( 'DB_NAME', 'database_name_here' ); 

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

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

New Settings:

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

/** The name of the database for WordPress */ 
define( 'DB_NAME', 'wordpress' );

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

/** MySQL database password */ 
define( 'DB_PASSWORD', 'password' );
  1. Once you have made those changes, go ahead and save the file using CTRL+X (to exit) and Y and Enter (to save changes, and close the file).

Step 5) Setup through wp-admin and verification

  1. Now, let’s verify that your WordPress install is working. You should see something like the following on your server page. Replace server_domain_name_or_IP with your server name or IP.  http://[server_domain_name_or_IP]/wp-admin


  1. If this is what you see then congrats!!! You have successfully installed WordPress on your Centos server. You can continue with the rest of the Wordpress setup to configure your wordpress blog.