Installing WordPress on CentOS 7 will be shown in this article. WordPress is the most popular content management system in the world that runs on PHP and MySQL databases. As a result, we are able to create and deploy a wide range of WordPress-based websites and blogs.
We need to set up the LAMP infrastructure first before we can install WordPress on CentOS 7. We’ll be able to get WordPress up and running after setting up LAMP.
What Is WordPress?
WordPress is a very popular open-source blogging and website tool. WordPress works with the popular PHP language and MySQL database. The tool was launched in 2003 as a simple single-bit code blogging system. It gradually became a completely diverse, extensive, complete, and comprehensive content management system. It is now proud to have one of the largest self-hosting blogging tools in the world. It currently manages 22% of all newly created websites. It includes more than 20,000 plugins alone to provide access to custom functions and capabilities.
Prerequisites To Install WordPress
First of all, you need a VPS with Centos 7 OS, make sure you have access to the system functions as a root user. A cheap Linux VPS with 2GB RAM, 2Core CPU, and a minimum of 20GB Storage can meet your needs. Also, before starting to install WordPress, you should make sure that the LAMP package (Linux, Apache, MySQL, PHP) is installed on your server.
Step 1: Download WordPress
To Install WordPress, the first installation step is to download WordPress. You must download WordPress from the website using the wget command as below. The wget package should be installed on your CentOS VPS by default. If you do not have this package, first enter the command yum install -y wget. Now use it to install WordPress.
The above command helps you to download the WordPress installation package in a concise way. This package will be downloaded directly to your user directory. You can now decompress the package with the following command.
tar -xzvf latest.tar.gz
The above command will extract the downloaded WordPress files from the package. You are now ready to move on to the second step.
Step 2: Create Database And WordPress User
After you have extracted the WordPress installation files, you will see them in a directory called WordPress in the home directory. Next, you need to create a new MySQL directory for WordPress. To do this, you must log in to MySQL Shell using the following command.
mysql -u root –p
You must be logged in with a password defined for MySQL. Do the following now:
Create a WordPress database.
Create and introduce a user in that database.
After those steps, you will be asked to assign a new password to that user.
It is important to remember that many MySQL statements must end with a semicolon (;). Otherwise, your commands will not be recognized.
Create A WordPress Database
The first step was that you need to create a database. In this tutorial, this database is named WordPress1. Of course, you are free to use the name of the database you see fit. Use the following command to create a database.
CREATE DATABASE wordpress1;
Introduce A User To The Database
In the next step, you must create and introduce a new user. You can replace the database, name, and password values used below with the values you want.
CREATE USER wordpressuser1@localhost;
Set A User Password
After creating the user, you must set the password for the new user. Use the following command for this purpose.
SET PASSWORD FOR wordpressuser1@localhost= PASSWORD(“password123”);
Set Accesses And Privileges
You must complete this step by granting all permissions to the newly created user. Please note that you should not miss this step! Because you will no longer be able to install WordPress. Please use the following command to do this.
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser1@localhost IDENTIFIED BY ‘password123’;
Next, you must restart MySQL using the following command.
After completing the above steps, now is the time to exit the MySQL shell by entering the following command.
You have now successfully exited the MySQL shell. It’s time to move on to the third step.
Step 3: WordPress Configuration Settings
To create a new and usable WordPress configuration, in the process that you install WordPress, you must first find the WordPress configuration file located in the WordPress directory, then copy it to a whole new file. It can then be edited. Use the following command for this purpose.
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Additionally, you must open the WordPress configuration by entering the following command.
You should search for the fields listed below. Then replace the exact details for your database name, username, and password.
This information is as follows:
“DB_NAME” is the name of the database we are building for WordPress. For example: (DB_NAME: wordpress1)
Similarly, DB_USER and DB_PASSWORD are the username and password of this database. For example: (DB_USER: wordpressuser1) and (DB_PASSWORD: password123)
You must save the changes made above before exiting and this will take you to the end of the third step.
Now you can move on to the fourth step.
Step 4: Copy Files
The process of loading WordPress on the server is almost complete. Only the last step, ie transferring the extracted WordPress files to the root directory of the website, remains. Do this using the following command. This is a fresh installation, also you can move your existing WordPress website on VPS.
sudo cp -r ~/wordpress/* /var/www/html
From now on, you can continue to install WordPress on its own simple and user-friendly online form! However! The existing WordPress form requires a special PHP module to run. If this module has not been installed on your server yet, do not worry. You can download the php-gd module using the following command.
sudo yum install php-gd
You have now successfully downloaded the required PHP module. You can run the existing WordPress form flawlessly. The last important point is that you must restart Apache with the following command:
sudo service httpd restart
By doing this, you will reach the end of the fourth stage. You can now go through the final step.
Step 5: Go To The WordPress Installation Online Page
Following the steps above will take you to the WordPress online installation page easily. All you have to do to access the installation page. To do this, you should add /wp-admin/install.php to the extension of your website domain or IP address of your website (for example 192.168.1.50/wp-admin/install.php). Then complete the online short form with the requested details.
In this tutorial, we checked how to install WordPress on CentOS 7 using the LAMP service. After installing WordPress, if you wish to connect your domain to the IP of the Server, you can easily point the domain to your IP address inside your domain control panel.
I wish you’ve enjoyed this post and you’ve found your answers. Please do not hesitate to share your opinions with us.