Setup WordPress with Nginx on Ubuntu VM at Azure

In the last article we installed MySQL, before that we installed and configured PHP. Now it is time to install WordPress, make a few changes to our MySQL setup and finally create a WordPress blog in our own Ubuntu Azure cloud environment.


  1. Install and Setup Nginx on Azure with a Ubuntu VM
  2. PHP with Configuration
  3. MySQL
  4. Setup WordPress
  5. Configure Nginx and WordPress

Please be aware that the steps I describe in this article may cost you money. Please see the Azure pricing page first.

As always we start with an update of our system:

$ sudo apt-get update -y
$ sudo apt-get upgrade -y 

Download WordPress

To download WordPress we will make use of the wget command, it will simply download the latest WordPress version.

$ wget

Nginx WordPress Download Azure

Next we want to unpack the file.

$ tar -xzf latest.tar.gz

If we take a look in the folder, we will find a wp-config-sample.php:

$ cd wordpress
$ ls
index.php        wp-blog-header.php    wp-includes        wp-settings.php
license.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.php
readme.html      wp-config-sample.php  wp-load.php        wp-trackback.php
wp-activate.php  wp-content            wp-login.php       xmlrpc.php
wp-admin         wp-cron.php           wp-mail.php
$ nano wp-config-sample.php

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

In the next step we want to change the sample settings, to match our environment.

Create a new MySQL Database

In the last step we configured MySQL, but we did not set a user (we do not want to use the root account here).

So lets create a new user – first login to your database.

$ mysql -u root -p

Then create a new user and a password:

mysql> create user 'your-username'@'localhost identified by 'password';

Next we want to create a new database:

mysql> create database `my-new-db`;

Last we grant and flus the privileges, exit MySQL and restart the service:

mysql> grant all privileges on `my-new-db`.* to 'your-username'@'localhost';
mysql> flush privileges;
mysql> exit;
$ sudo /etc/init.d/mysql restart

Config WordPress

Now we have all components setup and we can start to fill the fields in the WordPress config file with our database account.

$ mv wp-config-sample.php wp-config.php
$ nano wp-config.php

Just enter your new database name, user and password in the frist three fields.
For example:

define('DB_NAME', 'my-new-db');

When you scroll down you can see the auth keys and salts section. Just hit this link and copy paste the result.

Then hit CTRL-X, Y and ENTER.

Next we want to move the content of our WordPress folder to the default Nginx www root, which we configured earlier in this series:

$ sudo mv * /var/www/html

If we now hit our site, we will receive the following error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

So lets install the MySQL php extension:

$ sudo apt-get install php5-mysql -y

If everything worked out, you should now see the WordPress setup.

Nginx Azure WordPress Ubuntu Setup

In the next article we will change a few points in the Nginx config for our WordPress installation.

You may also like...