Wordpress Deployment to Awanio

Before deploying a Wordpress website, the following general things are needed:

  • Awanio Account [register]
  • Registered SSH public key on the Awanio dashboard page for you development machine [quick start]
  • Project and application for the deployment with sufficient credits [quick start]
  • Git URL of the project to push the code to. The format is git@awan.io:TEAM/APP_NAME.git
  • awan.yml file that is placed in the top application folder

After these prerequisites are present, the following 5 steps need to be taken to deploy the application to Awanio: 1. Create database resource 2. Download, extract and configure Wordpress 3. Add the awan.yml configuration file to the project 4. Initialize the Git repository and add awan as Git remote 5. Deploy to Awanio 6. Configure and enjoy Wordpress!

1. Create database resource in Awanio project

  1. Login to Awanio and navigate to your project page.
  2. In the left menu navigate to Resources and click on ADD RESOURCE.
  3. In the popup give your resource an unique name e.g. wordpress-db, set the resource to mariadb:xx.x and select the required instance type (we advice to use a minimum of 512 MB RAM, 1 vCPU).
  4. Click on CREATE and select the created resource from the list.
  5. Take a note of the environment variables table at the bottom of the page.
  6. Navigate to the application that you will use for the website. At the bottom of the page at the Environment Variables section, click on SET VARIABLES. In the popup enter the environment variables as noted from the resource page in the following format:
  1. Done.

2. Download, extract and configure Wordpress

2.1. Download and extract Wordpress

Download the latest wordpress from this page https://wordpress.org/latest.zip. Then extract the package in a folder, we named ours wordpress-site. The folder should now at least contain the following items:


2.2. Configure Wordpress

Rename the wp-config-sample.php file to wp-config.php. Open the wp-config.php file and edit the following sections:

$dbName = getenv('DB_NAME') ?? 'wordpress';
define('DB_NAME', $dbName);

/** MySQL database username */
$dbUser = getenv('DB_USER') ?? 'root';
define('DB_USER', $dbUser);

/** MySQL database password */
$dbPassword = getenv('DB_PASSWORD') ?? '';
define('DB_PASSWORD', $dbPassword);

/** MySQL hostname */
$dbHost = getenv('DB_HOST') ?? 'localhost';
define('DB_HOST', $dbHost);

Still in the wp-config.php file, please edit the Authentication Unique Keys and Salts section. This is important to increase the security of your Wordpress application.

define('AUTH_KEY',         'CHANGE_THIS_VALUE');
define('NONCE_KEY',        'CHANGE_THIS_VALUE');
define('AUTH_SALT',        'CHANGE_THIS_VALUE');
define('NONCE_SALT',       'CHANGE_THIS_VALUE');

All applications in Awanio use SSL termination. This means from user to cloud balancer data transfer via https. While from the balancer to your application, the communication line uses http. This will cause an issue because Wordpress will assume the application is run via http. For that, please add the following two variables under the WP_DEBUG constant setting in the wp-config.php file

if($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;

3. Add the awan.yaml configuration file

Awanio requires the awan.yaml configuration file in the root of the repository, in the wordpress-site folder. Create the awan.yml file in the main (root) folder. Paste the content in the awan.yaml file, check out the reference for more options:

version: '1.0'
    type: php
    version: 7.1
    doc_root: ./
    storage_dir: /code/wp-content

4. Initialize Git and add awan as Git remote

4.1. Initialize

Initialize the Git repository if you haven't done it before by executing this command within the wordpress-site folder:

git init

4.2. Add remote

Add Git remote Awanio to the project:

NOTE: modify the command by using your own TEAM and APP_NAME.

git remote add awan git@awan.io:TEAM/APP_NAME.git

5. Deploy to Awanio

The application is now ready for deployment, use the command to commit everything and to push it to Awanio:

git commit -a -m "Deployment v1.0"
git push awan master

6. Configure and Enjoy

After the deployment is complete, please check your website at https://app-name.onawan.eu. Now configure your website as usual.

NOTE: modify the URL by using your own application URL.