Archives For wordpress setup

Already installed LAMP or LEMP (Nginx with PHP, Mysql) on your Ubuntu Server? This time I’m going to show you how to install WordPress CMS.

WordPress is a popular blogging tool and a content management system (CMS) based on PHP and MySQL. It’s free and open-source.

To install WordPress, first login your Ubuntu Server as root, then follow the steps below:

1.) Create Mysql Database and User for WordPress.

  • First log into Mysql as root user:
    mysql -u root -p
  • Type in the root password to get past.

  • Create a database. Change database-name in code to whatever you want.
    CREATE DATABASE database-name;
  • Create an user. Change database-user in code to whatever you want.
    CREATE USER database-user@localhost;
  • Give a password to the user just created. Change password-here in code.
    SET PASSWORD FOR database-user@localhost= PASSWORD("password-here");
  • Grant all privileges to the new user.
    GRANT ALL PRIVILEGES ON database-name.* TO database-user@localhost IDENTIFIED BY 'password-here';
  • f.) Finally, refresh Mysql:
  • g.) Exit Mysql sell

2.) Download WordPress and setup the configuration.

  • Download the latest wordpress:

    Then extract:

    tar -xzvf latest.tar.gz
  • Copy the sample configuration file to make a backup.
    cd wordpress && cp wp-config-sample.php wp-config.php
  • Edit the configuration file:
    vi wp-config.php

    Press I to start editing, Esc to stop editing. Press :, then type wq to save and exit, type q! to exit without save.

    Then change the section of database-name, database-user, password-here.

    // ** MySQL settings – You can get this info from your web host **
    define(‘DB_NAME’, ‘database-name’);

    define(‘DB_USER’, ‘database-user’);

    define(‘DB_PASSWORD’, ‘password-here’);

3.) Setup the permissions.

    Give ownership of the directory to the apache or nginx user by running following commands one by one:

    sudo rsync -avP ~/wordpress/ /var/www/
    cd /var/www/
    sudo chown www-data:www-data * -R 
    sudo usermod -a -G www-data username

4.) Finally in your browser go to IP or domain/wp-admin/install.php and start installing.