Wordpress installation via command line


May 16, 2014
WordPress is a famous Content Management System(CMS) running with PHP and MySQL. We can setup WordPress in different ways. The most used method is by using a tool such as Softaculous and install it graphically. Here we are describing the steps to do the WordPress installation via command line with an Apache server and MySQL on a Centos 7 server.
  1. Create a database and user to use with the WordPress.

    a. Login to MySQL:
    mysql -u root -p
    Provide the MySQL root password and log in.

    b. Create a new database:
    CREATE DATABASE wordpress;
    Replace the DB name 'wordpress' with the actual name you needed.

    c. Create a user:
    CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';
    Replace the user 'wordpressuser' with actual one and provide the actual password you need to use in the place of 'password'.

    d. Set up the privileges:
    GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
    Replace the DB 'wordpress',user 'wordpressuser' with actual ones and provide the correct password in the place of 'password'.

    e. Then run the following commands:

  2. Download and install WordPress:

    a. Download WordPress:
    wget :wordpress.org/latest.tar.gz
    b. Extract the file:
    tar xzvf latest.tar.gz
    c. Move the WordPress files inside the extracted directory to the actual Apache home directory. If you are using any hosting control panel, the directory might be different such as /home or /var/www/ etc. based on the panel. Here I am considering the home directory as /var/www/html/
    cp -avr wordpress/* /var/www/html/
    d. Access the home directory and set the required ownership as per the control panel:
    cd /var/www/html

    chown -R apache:apache /var/www/html/
    e. Rename the configuration file and edit the DB details:
    mv wp-config-sample.php wp-config.php

    vi wp-config.php
    Find the line specifying the DB name, username, and DB password and replace them with the actual ones you set in the first step:

    define('DB_NAME', 'wordpress');

    define('DB_USER', 'wordpressuser');

    define('DB_PASSWORD', 'password');

    Replace the DB 'wordpress',user 'wordpressuser' with actual ones and provide the correct password in the place of 'password'.

    Once done save the file.

  3. We can access it with the site URL from the browser and you will get the WordPress initial setup page and you are done.

Latest Hosting OffersNew Reviews


Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.