Sourcevoid Docs

Everything you need to get started with Sourcevoid, pick your favorite language and let's get started!

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Deploy WordPress


Download the latest version of WordPress

Click this link to download the latest version, or use the curl example below.

# Download wordpress
curl -O

# Unzip 

# Enter directory
cd wordpress

Add sourcevoid.yaml

Create a new file called "sourcevoid.yaml" containing this content:

# Select the php runtime
runtime: php

# Enable the embedded nginx (part of the runtime)
nginx_enable: true
nginx_include: include.conf

# Specify a start command for php
start: php-fpm --nodaemonize -y /home/cuser/etc/php-fpm.conf

Add include.conf (for nginx)

Create a new file called "include.conf" containing this content:

location / {
  index index.php index.html index.htm;

location /wp-content {
  alias /home/cuser/disks/wp-content;

Add wp-config.php

Create a new file called "wp-config.php" and add this to the file:

 * The base configuration for WordPress on Sourcevoid.
 * It is based on the "wp-config-sample.php" sample config.
 * The lines 
 * This file contains the following configurations:
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * @link
 * @package WordPress

// ***************************************************************
// ** Sourcevoid custom settings starts                      ** //

/** Get database details from env variables set by the platform */
define('DB_NAME', getenv('MYSQL_DATABASE'));
define('DB_USER', getenv('MYSQL_USERNAME'));
define('DB_PASSWORD', getenv('MYSQL_PASSWORD'));
define('DB_HOST', getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT'));

/** 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', '');

/** Sourcevoid is always HTTPS, here we tell WP that. */
$_SERVER['HTTPS'] = 'on';
define('WP_HOME', getenv('APP_URL'));
define('WP_SITEURL', getenv('APP_URL'));

 * Setup a data disk for wp-content, this setting assumes that
 * a data disk has been created and attached to this app with 
 * the mount path listed below, edit if needed.
define('WP_CONTENT_DIR', '/home/cuser/disks/wp-content');

 * We set SERVER_NAME as Nginx otherwise sets to "_" and email
 * address generation fails.
 * See WP issue:

// ** Sourcevoid custom settings ends                        ** //
// ***************************************************************

 * Authentication Unique Keys and Salts.
 * Change these to different unique phrases!
 * You can generate these using the {@link secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 * @since 2.6.0
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');


 * WordPress Database Table prefix.
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
$table_prefix  = 'wp_';

 * For developers: WordPress debugging mode.
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 * @link
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

/** Copy wp-content on to data disk on first run */
exec('bash -c "if [ -d /home/cuser/disks/wp-content ] && [ ! -f /home/cuser/disks/wp-content/index.php ] ; then cp -r /home/cuser/source/wp-content/* /home/cuser/disks/wp-content/ ; rm -rf /home/cuser/source/wp-content ; fi"');

Create unique Authentication Unique Keys and Salts

Edit the "wp-config.php" by replacing the rows in the section "Authentication Unique Keys and Salts" with unique values generated by WordPress official secret key service. Simply copy the value from the link below and replace the placeholder values currently present in the "wp-config.php" settings above.

Secret generator

Package WordPress a zip archive

Now that we have prepared the default WordPress installation, we package it up into a zip file again including the new settings files.

# Move one step above wordpress directory
cd .. 

# Create zip file (named in format "")
zip -r $(date +%Y-%m-%d-%H-%M) wordpress

Create a Sourcevoid app

Click the "NEW" menu option and select "Application", then enter a name of your app. We wait with deploying the code as we need to create a the data disk and database first.

Create a data disk

To separate the core WordPress code from file uploads and the likes we setup a dedicated data disk for "wp-content". Click the "NEW" menu options and select "Disk", enter disk name "wp-content" and click "Create".

Note that if you use a different disk name than "wp-content" or change the default mount path from "/home/cuser/disks/wp-content" to something else, you need to edit the config file above accordingly. The wp-config.php file above assumes a data disk will be mounted at "/home/cuser/disks/wp-content". It's okay to change it, just remember to update the paths in the config.

Attach the data disk

Click on "Storage -> Data disks", then click the name of the disk, "wp-content". In the next view select your app from the "Attach disk to app" drop down list and click the "Attach" button.

Create a MySQL database

Click the "NEW" menu option and select "Database", then enter a name of the database and select "MySQL" as the database type and press "Create". Wait a about 30-60 seconds if this is your first MySQL database or just a few seconds if you already have a MySQL container setup.

Connect the database to your app

Click the "Databases" menu option and the "MySQL". All your MySQL databases are listed here, now click the "Manage" button in the "Credentials" column to add the MySQL credentials to your newly created app. In the next view select your app from the drop down list and press "Add". Now the credentials have been added, to double check you can open the app view under "Apps -> app_name" and click the "Secrets" button, it will now contain the details needed to connect from WordPress to MySQL.

Deploy WordPress

Click the "Deploy" menu option and select "Source Archive". Then select your app in the "App to deploy" drop down if not already selected. Click the "Upload archive" button to upload your new custom WordPress installation from the steps above. Click "Deploy", within 5-10 seconds you new app will be live.

Complete the default WordPress installer

Click on the link on the app view that has the same name as the zip file you uploaded. When you open the site for the first time you will be presented with the default WordPress installer asking you to select language and enter basic site info. The first time you open the installer it takes a second or two to load.

Add an email plugin

Sourcevoid does not provide any email service on our own, instead we recommend using one of the many companies that specializes on sending emails with high delivery rates. Two of the biggest providers are SendGrid and SparkPost, we recommend using one of their official WordPress plugins for production sites. As of May 2017 SendGrid offers a free 30 day trial while SparkPost offers a completely free plan that is more than enough for most small to medium sized sites. Below are instruction to add their official plugins to your WordPress installation. Note that you only need one of them.

Install SendGrid for WordPress

In you WordPress dashboard, click the "Plugins" menu item, followed by "Add New". In the search bar in the top right corner, enter "SendGrid" and press enter. Spot the official SendGrid plugin by finding the text "By SendGrid" after the short plugin description. Click the "Install Now" button on the plugin, then wait a few seconds and then click the "Activate" button. Now click the "Settings" link at the "SendGrid" row among the plugins. Fill out your SendGrid Credentials and you are done!

Install SparkPost for WordPress

In you WordPress dashboard, click the "Plugins" menu item, followed by "Add New". In the search bar in the top right corner, enter "SparkPost" and press enter. Spot the official SparkPost plugin by finding the text "By SparkPost" after the short plugin description. Click the "Install Now" button on the plugin, then wait a few seconds and then click the "Activate" button. Now click the "Settings" link at the "SparkPost" row among the plugins. Fill out the SparkPost settings and you are done!

Note on promoting environments

When you make a new deployment to an app that has already been deployed once, it will first be served under a environment specific url (eg. ""), not the main url of the app ("eg. ""), so you an check it before switching over. If you deploy to an app that already have one of more older environment the WordPress installer gets a little confused by the two different urls, because of that you need to promote the environment by clicking the "Promote" button in the app view and then click on the link to the site.

Deploy WordPress