Installing WordPress on Ubuntu 12.04

By | February 4, 2015

WordPress is a content management system originally developed for blogging, but has beed greatly expanded through widgets, themes and plugins. Complete the following steps to install WordPress on Ubuntu 12.04.


  • Clean installation of Ubuntu 12.04,MySQL,Apache and PHP on your server.
  • WordPress software from downloaded uncompressed in a local repository, using
    tar –xzvf latest.tar.gz
  • User needs to have root privileges and be logged in as root or su.
  • System packages installed:

Create the WordPress Database and MySQL User

  • After we unzip the wordpress files, they will be in a directory called wordpress in the home directory.
  • Log into the MySQL Shell and create a new MySQL directory for WordPress.
    mysql -u root –p
  • After logging in using you’re MySQL root password, create a WordPress database:

Note : Keep in mind that all MySQL commands must end with semi-colon.

(For this example, we will use the database name WordPressdb.)

CREATE DATABASE wordpressdb; Query OK, 1 row affected (0.00 sec)
  • Create the new user. You can replace the database, name, and password, with whatever you prefer:
    CREATE USER [email protected]; Query OK, 0 rows affected (0.00 sec)
  • Set the password for your new user:
    SET PASSWORD FOR [email protected]= PASSWORD("password"); Query OK, 0 rows affected (0.00 sec)

Note: For security purposes, you would obviously not use “password” for your password. Be sure to assign a secure password in this line instead.

  • Grant all privileges to the new user. Without this command, the wordpress installer will not be able to start up:
    GRANT ALL PRIVILEGES ON wordpressdb.* TO [email protected] IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec)
  • Refresh MySQL:
    FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
  • Exit out of the MySQL shell:

Configure WordPress

  • Copy the sample wordpress configuration file from the wordpress directory, into a new file.
  • Edit the new file to create a new usable wordpress config file:
    cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
  • Open the wordpress config:
    sudo nano ~/wordpress/wp-config.php
  • Find the section that contains the field below and substitute in the correct name for your database, 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');
  • Save and Exit.

Copy the Files

  • Transfer the unzipped WordPress files to the website’s root directory.
    sudo rsync -avP ~/wordpress/ /var/www/
  • Set the permissions on the installation. First, switch in to the web directory:
    cd /var/www/
  • Give ownership of the directory to the apache user.
    sudo chown www-data:www-data * -R sudo usermod -a -G www-data username
  • Install the following php module on your server, to enable the WordPress installation form online. Download php-gd:
    sudo apt-get install php5-gd

Confirm setup

  • Review your new set up at http://your-server-ip-or-hostname/wp-admin/install.php

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.