WordPress has been one of the most popular options available for creating open-source websites and blogging with significant reliability on MySQL and PHP machine languages. Being a flexible system, it has become quite popular globally and has since garnered over 20,000 plugins that provide a number of applications to users and developers. Such scalability makes it a worthy CMS platform for day-to-day web 2.0 usage.
Moreover, its open source applications make it flexibly usable with various operating systems. Among them, a popular one used is Linux distribution OS that uses various software versions called as CentOS. The current version, known as CentOS 7, has been one of the many software that developers tend to use on their WordPress-enabled Linux distribution systems. But, it is to be noted that the process is not that simple as witnessed for simpler operating systems. So, if you are facing problems in installing WordPress on CentOS 7 server.
What initial requirements are needed?
Before we initiate with the installation process, there are certain things that you need to take care.
- Installing CentOS 7 server is configured with a user that does not have root access benefits, but does have sudo privileges.
- Need of LAMP stack, which is an acronym for Linux, MySQL, and PHP, on the CentOS 7 server. This step would require the user to install the stack first before moving on to the installation step for WP.
Database Setup for WordPress and MySQL
The initial step is to configure the two databases with the relevant information. WordPress may find the need of a user as well as a database to keep it running with the system. On the other hand, MySQL amy already have a database installed by the name, MariaDB.
To execute this installation, the user will have to access the account as an administrator in MySQL using the following command:
mysql -u root -p
Now, the user will have to enter the same password that was needed to access the admin account during the installation of MySQL. Once the password has been accepted, the user will have access to the MySQL command prompt. With this step fulfilled, the next step will be to generate a database, which is controllable through WordPress. While the name given to it is as per the choice of the user, here we will call it as Princeton.
CREATE DATABASE princeton;
Next comes the step where the user will have to create a MySQL account exclusively to be supported with WordPress database. The reason for this account is to have a tighter security with restricted access, which is meant only for the ones with admin privileges.
Let this account be known by the name princetonuser. This account can be accessed with a password called pr1nceton. While the above-mentioned name and password is for sample use, you need to think of a more secure alternative for your account so that it may not be easily accessed by other users. The command for it will be:
CREATE USER princetonuser@localhost IDENTIFIED BY ‘pr1nceton’ ;
Once this command has been processed, the user should now have an exclusive account as well as a database for WordPress. However, do not that there is still no access to the database. This can be done by linking the two. For this, the below-mentioned command can be used:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY ‘password’ ;
After getting access to the database, MySQL will have to be notified about the updates made by the user. For this, the following command of flush the privileges will have to be used:
Once these commands have been executed, the user can leave the MySQL command prompt using the command:
With this command, the user should now come back to the SSH command prompt.
Before moving on to downloading WordPress, the user needs to install a PHP module to ensure that the complete process runs smoothly. Furthermore, the need of this specific module is to prevent a problem where the user is unable to resize the thumbnail images properly. One can directly get access to the module from the default CentOS repositories by the help of yum command. This particular command goes something like this:
sudo yum install php-gd
Once this command has been input, the user will have to consider rebooting the Apache server so that the new module is acknowledged by the system. For this, the command is:
sudo service httpd restart
After this, the user can move on to download and install WP. It is to be noted that WordPress will provide with its latest update. This makes the process smoother. One can do this by the following command:
The above link will download a zip file that will have all the WordPress files in it. The following command will extract those files into the WordPress directory:
tar xzvf latest.tar.gz
The above command lets the user create a new directory called as princeton that has now become a part of the home directory. After this, complete the unpacking of files to the Apache’s root, where any visitor to your website will be provided with these unpacked files. In addition, the user can find the WordPress files by using the rsync command that keeps the permissions completely safe by default.
sudo rsync -avP ~/princeton/ /var/www/html/
The rysnc command helps the user in copying all the data to the root director after unpacking from the newly created directory: /var/www/html/. However, the user will still require to create a WP folder to store the newly uploaded files. For this, the following command can help:
After the above step, the user can assign ownership and permissions to the WordPress files. This too is needed for enhancing the security of the system, but it still lets WordPress carry out all its processes without any hassle. The following command can help with this:
sudo chown -R apache:apache /var/www/html/*
Once this has been done, the web server will now have the necessary permissions to create or modify WP files as well as upload the latest content to the CentOS 7 server.
How to configure WordPress?
Even though there is an option to configure the WordPress files with the help of web UI later, but there is still a need to link the WordPress and MySQL beforehand with the help of command prompt. For this, the user will first have to enter the root directory of Apache server where the user initially installed the WP files: cd /var/www/html.
Most devs already know the file wp-config.php that is of high significance in WordPress. The user will require a sample configuration file, which has default settings enabled. All that is needed now is to copy this sample config file to the location of the config file so that WP can identify and use the file.
cp wp-config- sample.php wp-config.php
After adding the file, the user can now use it with the help of text editor.
After this, the user will need to make changes to the parameters in this file that offer information linked to the database. This involves finding the section called MySQL settings and then modifying the variables such as DB_NAME, DB_PASSWORD, and DB_USER so that WordPress can securely link and approve the generated database.
Use the following commands to add in the parameters with the information related to the database generated.
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
Only the above-mentioned values require modifying, after which the user can save and exit the file once finished.
How to install the files with the help of the Web UI?
Once the files have been added to their required locations and configured, the user can now install WP with the help of web UI. This can be achieved by going to the server’s doman name or public IP address.
The user can choose the language for installation as preferred by him or her and click continue. This brings him/her to the configuration page, where the admin account fields are required.
Once the fields have been filled, click on the install button that is located at the bottom of the page. WP now approves of the installation and will ask you to log in with the help of the created details. Pressing login will require the user to enter the generated details of the admin account. Now, the user can access the WordPress dashboard.
Installation of WP with LAMP on the CentOS 7 server is finally complete.
Neither the company, any of its subsidiaries, nor any other programmer/developer writing on behalf of the company, is responsible for any kind of security issues faced during the execution of any of the codes. Please backup your system before using any of these commands.