Search Our Database

Install WordPress in CentOS with NGINX Web Server

Last updated on |
by

First refer to this guide to setup LEMP on your server. LEMP comes with Nginx (Engine X) web server, MySQL & PHP. We first need to create a database for WordPress to use before starting the installation.

 

Step 1: First, make sure your MySQL service is running using:

service mysqld start

 

Step 2: Access your MySQL root account using the login credentials set during the installation of LEMP, by typing:

mysql -u root -p

 

Step 3: Type in your MySQL root password to begin using MySQL. Create a database for WordPress named “wordpress” by typing:

1

 

Step 4: Then, create a new user for the database:

2

 

Step 5: Set a password for the wordpress user account:

3

 

Step 6: Grant all privileges of “wordpress” database to the created user:

4

 

Step 7: Flush the privileges to refresh MySQL and its configurations:

5

 

Step 8: The database is now ready to be used by WordPress. There are 2 ways to download WordPress:

  1. Go to the website and download the .zip or .tar.gz file. Unzip the file and extract the “wordpress” folder, then use FTP software to upload it to Nginx default root folder: /usr/share/nginx/html/
    Then access it by typing http://your-ip-address/wordpress in your browser’s URL and follow its instructions on setting up WordPress. Use the credentials set when creating the “wordpress” database to link WordPress to the database that you have created.
  2. Change your directory to /usr/local/src and download the WordPress installation files using wget (if wget is not installed use “yum install wget”), then untar it.
    After that, go into wordpress folder and create a new config file by copying contents from a sample file.
    Edit the config file so that WordPress can be linked to the MySQL database.
    Make a new folder named “wordpress” in your Nginx root folder /usr/share/nginx/html.
    Then, copy all the wordpress files into the folder you have just created. The full sequence of commands is below:

    cd /usr/local/src
    wget http://wordpress.org/latest.tar.gz
    tar -xzvf latest.tar.gz
    cd /usr/local/src/wordpress
    cp wp-config-sample.php wp-config.php
    vi wp-config.php
    6
    mkdir /usr/share/nginx/html/wordpress/
    cp -r /usr/local/src/wordpress/* /usr/share/nginx/html/wordpress/

Now Access the WordPress page by typing http://your-ip-address/wordpress in your browser’s URL and follow its instructions on setting up WordPress.

 

Step 9: Proceed to login to WordPress.

7