It’s time for the fun part of installing WordPress. Full instructions are supplied in more detail at WordPress’ Codex.

Upgrade to the latest Ubuntu distribution and its packages:

sudo apt-get dist-upgrade

Create a www directory with permissions for the Apache web server:

sudo mkdir /var/www
sudo chown www-data:www-data /var/www
cd /var/www

Download the latest version of WordPress, expand the archive and set permissions:

sudo wget
sudo tar -xzvf latest.tar.gz
sudo chown -R www-data:www-data wordpress

Install MySQL Server

Install the MySQL Server package:

sudo apt-get install mysql-server

You’ll be asked to provide a user name and password. Make note of your choices for use during the setup process.

MySQL Server Password Request

MySQL Server Password Request

Configure the MySQL Database. Change user name and password below to whatever you selected during the installation:

mysql -u root -p
create database wordpress;
grant all privileges on wordpress.* TO "your-mysql-username"@"localhost" identified by "your-mysql-password";
flush privileges;

Setup Your WordPress Apache Site

If you did not choose an Amazon AWS AMI which pre-installed Apache, you may need to install it now:

sudo apt-get install php5 libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql

Now, it’s time to create a site configuration file for your Apache server to host WordPress:

cd /etc/apache2/sites-available

Let’s create a new file to edit:

sudo nano wordpress

Paste in the sample site file below and be sure to replace the naming convention for your domain name:

<VirtualHost *:80>
   DocumentRoot /var/www/wordpress
   DirectoryIndex index.php
   <Directory /var/www/wordpress/>
      AllowOverride All
      Order Deny,Allow
      Allow from all

Tell Apache to enable the site and reload:

sudo a2ensite wordpress
sudo service apache2 restart

Configure WordPress

Now, we’re ready to tell WordPress about the database and your blog. First, we’ll temporarily change the permissions on your wordpress directory:

cd /var/www
sudo chmod -R 777 wordpress

Open a web browser and navigate to your domain name e.g.

Fill out the database information that WordPress requests using your choices above. The process will look something like this:

Now, let’s lock down the permissions for the WordPress installation for security:

sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \;

Let’s also make manual updates to the wp-config.php file:

sudo nano /var/www/wordpress/wp-config.php

Add the following configuration lines above the stop editing line:

define('FS_METHOD', 'direct'); // for automatic plugin installation
/* That's all, stop editing! Happy blogging. */

Try logging into the WordPress Administration system. Visit and enter the user name and password you chose during the installation process:

WordPress Administrator Login

WordPress Administrator Login

If you’re successful, it should look something like this:

WordPress Administrator Dashboard

WordPress Administrator Dashboard

Congratulations on your new WordPress installation. Now, it’s time to build the foundation for super fast performance. Next step is Installing Varnish.

Please feel free to post corrections, questions or comments below. You can also follow me on Twitter @reifman or email me directly.

About The Author

  • jdcncde

    If you get “ERROR: Site wordpress does not exist!” when trying to enable it in apache, change the file name to ‘wordpress.conf’. Apparently Ubuntu has changed the way Apache handles those files.

  • b.s. bisht

    This is good and informative post. it will help many users.
    To read another very good article illustrating easy
    steps to install wordpress with proper images is available


  • Carlos Bracho

    Hello, I think I did something wrong, I made every step but the IP is still pointing to apache:
    Can you help me

  • Analytics Team

    might be a stupid question but how do i get out from this screen when i type this:

    DocumentRoot /var/www/wordpress
    DirectoryIndex index.php

    AllowOverride All
    Order Deny,Allow
    Allow from all

    the next step i need to do is:
    sudo a2ensite wordpress
    sudo service apache2 restart

    but first i need to exit or save right? i have ^G for get help, ^X for exit, etc. i am total newbie on terminal. i am a website developer. pls HELP 🙂

    • Rich Sadowsky

      ^X to exit, then say Y to save. Make sure you name the file wordpress.conf, if you just name it “wordpress” as shown above it won’t work

  • Analytics Team

    i am stuck on this. when i type “sudo a2ensite wordpress” i get sudo: a2ensite: command not found