Channel framework startup tutorial - Appendix: Environment Setup

Step 1: Setup local WordPress

WordPress needs an RDBMS to store blog posts and comments. Here is one way to set up the database:

Create local DB (OSX instruction using Homebrew)

  1. Download and install Homebrew .
  2. brew install mysql
  3. mysql.server start May need to restart the machine if mysql.server start doesn’t work.
  4. mysql -u root -p with no password (Press enter at the password prompt). This will open the mysql command prompt.
  5. Run the following SQL in the mysql command prompt:

    1. CREATE USER 'wordpress'@'%' IDENTIFIED BY 'wordpress';
    2. CREATE DATABASE wordpress;
    3. GRANT ALL ON wordpress.* TO 'wordpress'@'%';
  6. To verify the wordpress user, run mysql -u wordpress -p in the terminal with password wordpress . The terminal should show a mysql prompt. Entering SHOW DATABASES; at the mysql prompt should show the wordpress database.

Now you can run WordPress by installing locally.

Run WordPress locally

  1. Make sure that the mysql server is running at localhost:3306 (if not, run mysql.server start ).
  2. Change directories to the sample integration service source directory.
  3. php -f scripts/test_database_connection.php
  4. If the command prints Connected successfully , php and mysql are working.
  5. Common causes for failure include:

    • MySQL is not running on the correct host and port.
    • Your php version doesn't contain the correct MySQLi library.
    • On Mac OS X, you can install php (WordPress recommends 5.6 as of 15th July 2016) through [ http://php-osx.liip.ch/ ].
  6. Get the latest WordPress source code from https://wordpress.org/download/ and unzip it.
  7. Change directories to the unzipped WordPress directory (where wp-login.php is located).
  8. Run php -S 127.0.0.1:25789 to start the WordPress server (the port number can be replaced by any unbound port on the machine).
  9. Go to http://127.0.0.1:25789 in a browser. WordPress will guide you through the setup.

You need to install two WordPress plugins - rest-api for responding to API requests and JSON Basic Authentication for authentication.

Install the "rest-api" WordPress plugin

  1. Open your local WordPress in a browser.
  2. Log in as admin/123456 or the username and password set up during WordPress config.
  3. Navigate to Plugins/Add New.
  4. Install the WP REST API plugin.
  5. Activate the WP REST API plugin.
  6. Verify the plugin is working by running curl http://<Url and port of the WordPress Instance>/wp-json/wp/v2/posts (for example, curl http://127.0.0.1:25789/wp-json/wp/v2/posts ). That should return a json that contains all the posts.

    • If curling the endpoint returns html instead of json, in WordPress, go to Admin > Settings > Permalink and change the setting to Post Link. That should fixes the issue. See Original Issue .

Install the "JSON Basic Authentication" plugin

  1. Click "Clone or download".
  2. Click Download zip and save file locally.
  3. In WordPress, navigate to Plugins/Add New.
  4. Click Upload Plugin.
  5. Choose the file you downloaded previously.
  6. Install the JSON Basic Authentication plugin.
  7. Activate the JSON Basic Authentication plugin.
  8. Verify the plugin is working by running curl -v --user <username>:<password> http://<Url and port of the WordPress Instance>/wp-json/wp/v2/users . (for example curl -v --user admin:123456 http://127.0.0.1:25789/wp-json/wp/v2/users ). You should get the list of WordPress users, and the http headers should include Server auth using Basic with user <username> . Add AppendixWordPressAuthScreenshot.png here WordPress is set up correctly now. Create some blog posts and comments on those posts using the WordPress UI - the comments will show up in Zendesk Support once you finish the tutorial.

Step 2: Setup Integration Service Environment

The tutorial integration service is written in Node using the Express framework. You can use any language or framework to build your own integration services. Zendesk recommends using OAuth and SSL with the external service whenever possible. Zendesk Support requires SSL when communicating with the integration service.

Setting up the Node/Express server

  1. Download node from [ https://nodejs.org/en/ ] and install it.
  2. nodenv local 5.7.0
  3. npm install Now your environment is set up for the tutorial.