Steps to Install Wordpress on CentOS Print

  • 117

How to Install WordPress on CentOS

WordPress is a popular free open-source website and blogging tool that works by using PHP and MySQL.Before you begin work on WordPress, you must ensure that Linux, Apache, MySQL, and PHP (LAMP) stack is installed on your server. Once the above preconditions are fulfilled, you are good to go and you may begin the process of installing WordPress on CentOS by following the steps below.

Step 1: Downloading the WordPress

As the first step in the process, you must download WordPress from the website by using the wget command:

         # wget http://wordpress.org/latest.tar.gz

The above command shall help you download the zipped WordPress package straightaway to the home directory of the user.

         # tar -xzvf latest.tar.gz

 The above command shall lead to the unzipping of the downloaded WordPress filesAfter you have managed to unzip the WordPress files, you will find them in a directory called WordPress within the home directory.

Step 2: Creating the WordPress Database and User

you need to create a new MySQL directory for WordPress. For that, you need to log into the MySQL Shell using the following command:

         # mysql -u root -p

You must log in here through your MySQL root password, and further create the following:

1. A WordPress Database

2. A User in the created database

Subsequently, you would be required to assign a new password for the WordPress database.

Please use the following command to create the database:

         mysql> CREATE DATABASE WordPress;

         Query OK, 1 row affected (0.00 sec)

Next, you are required to create a new user.

         mysql> CREATE USER wordpressuser@localhost;

         Query OK, 0 rows affected (0.00 sec)

Once the user has been created, you need to set the password for the new user by using the following command:

         mysql> SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");

         Query OK, 0 rows affected (0.00 sec)

After that, you must grant all privileges to the newly created user. Please note that if you miss this step, you would not be able to start the Wordpress installer. Please use the following command to do the same:

         mysql> GRANT ALL PRIVILEGES ON WordPress.* TO wordpressuser@localhost IDENTIFIED BY 'password';

         Query OK, 0 rows affected (0.00 sec)

Subsequently, you need to refresh MySQL using the following command:

         mysql> FLUSH PRIVILEGES;

         Query OK, 0 rows affected (0.00 sec)

Once done with the above steps, its now time to exit out of the MySQL shell by giving the following command:

         mysql> exit

You have now successfully exited out of the MySQL shell,

Step 3: Configuration of WordPress

First, you need to copy the sample WordPress configuration file, which is located in the WordPress directory, into an altogether new file that would need to be edited, thus creating a new and usable WordPress config. Please use the following command to execute the same:

        # cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

Further, you need to open the WordPress configuration by in the following command:

        # vi ~/wordpress/wp-config.php

You need to search for the section containing the fields given below, and replace with precise details for your database name, username, and password:

// ** 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', 'wordpressuser');

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

You need to save the changes made above before exiting.

Step 4: Copying the Files

The process of uploading WordPress to the server is almost complete. The final step remains to transfer the unzipped WordPress files onto the website's root directory by using the following command :

        # sudo cp -r ~/WordPress/* /var/www/html

You have now successfully installed WordPress, then you are required to restart the Apache server by using the following command:

        # sudo service httpd restart

Step 5: WordPress Online Installation Page

The above steps shall lead you to the WordPress Online Installation Page. All you need to do to access the page is add /wp-admin/install.php to your website's domain or IP address (for instance. sample.com/wp-admin/install.php), and complete the short online form with the requested details.


Was this answer helpful?

« Back