How to setup Wordpress on Idealstack

  1. Add a site in idealstack

    1. Give it a servername:

    2. Ensure that you set an SSH key (if you don’t already have an SSH key, create one):

    3. Save, and apply the changes to AWS

Install wordpress using WP-CLI (recomended)

We recomend the use of the wp-cli commandline tool to install wordpress. http://wp-cli.org/. Not only is it quicker than trying to download locally, extract & upload, but it's also scriptable (if you are doing a lot of this, sooner or later you'll be keen to automate the process).

Once the AWS changes have completed, you can connect to your site and install wordpress:

  1. Create a database for the site

  2. Connect to SSH

    1. Go to the site in idealstack and navigate to the ‘Connect’ tab

    2. Connect to the site with SSH using your preferred SSH client:

  3. Install wp-cli:
     

    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
    chmod +x wp-cli.phar
    mkdir ~/bin
    mv wp-cli.phar ~/bin/wp
    
  4. Install wordpress- update the details in square brackets as needed:

    cd ~/public_html
    wp core download #Download wordpress
    
    #Generate a random table prefix.  This is a good security enhancement
    PREFIX=wp_$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 11 | head -n 1)_
    
    #Create a configuration file.
    wp config create  --dbhost=database --dbname=[database_created_above] --dbuser=[user_created_above] --dbpass=[password_created_above] --dbprefix=$PREFIX
    wp core install --url=[example.com] --title=[Example] --admin_user=[supervisor] --admin_password=[strongpassword] --admin_email=[info@example.com]
    
  5. Optional, but highly recomended - install a caching plugin for wordpress.  
    wp plugin install --activate w3-total-cache
    

Install Wordpress by uploading a site using SFTP

The other option to install wordpress on an idealstack site is to upload it from your development machine.  This takes a little longer due to the need to transfer a large number of files over SFTP

  1. Setup wordpress on your own local machine
  2. Copy the site's files using your preferred SFTP client
  3. Upload the site's database
  4. Update the wordpress configuration file, wp-config.php to use the correct database username/password/hostname

Tips & Tricks

Setup wp-cron as a scheduled task

By default WP runs it's scheduled tasks on every page load, but this isn't great for performance.  We recomend you setup wp-cron as a scheduled task and disable this in wp-config.php

  1. Create a scheduled task. 
    1. Go to the site in idealstack, add a scheduled task
    2. Set the Schedule to rate(1 minute)
    3. Set the command to :
      cd ~/public_html && php -q wp-cron.php
    4. For the container, choose to use the same container as the site
    5. Your scheduled task settings should look like this
  2. Apply your changes to AWS
  3. Go to the bottom of the database settings in wp-config.php. Add the code below highlighted in red:
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    
    define('DISABLE_WP_CRON', true);