In this tutorial, we will show the process to install WordPress on CentOS 7. The world’s most popular content management system running PHP and MYSQL databases. So that we can design and launch all kinds of WordPress sites and blogs with it.
Before we install WordPress on CentOS 7, we should prepare the infrastructure which is LAMP. After installing LAMP, we will be able to download and install 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.
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.
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.
wget http://wordpress.org/latest.tar.gz
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.
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:
It is important to remember that many MySQL statements must end with a semicolon (;). Otherwise, your commands will not be recognized.
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;
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;
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");
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.
FLUSH PRIVILEGES;
After completing the above steps, now is the time to exit the MySQL shell by entering the following command.
Exit;
You have now successfully exited the MySQL shell. It’s time to move on to the third step.
To create a new and usable WordPress configuration, in the process 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.
nano ~/wordpress/wp-config.php
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.
ctrl+x
y
Press enter
Now you can move on to the fourth step.
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.
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.