Channel framework startup tutorial - Appendix: Environment Setup
WordPress needs an RDBMS to store blog posts and comments. Here is one way to set up the database:
- Download and install Homebrew .
brew install mysql
mysql.server startMay need to restart the machine if
mysql.server startdoesn’t work.
mysql -u root -pwith no password (Press enter at the password prompt). This will open the mysql command prompt.
Run the following SQL in the mysql command prompt:
CREATE USER 'wordpress'@'%' IDENTIFIED BY 'wordpress';
CREATE DATABASE wordpress;
GRANT ALL ON wordpress.* TO 'wordpress'@'%';
- To verify the
mysql -u wordpress -pin the terminal with password
wordpress. The terminal should show a mysql prompt. Entering
SHOW DATABASES;at the mysql prompt should show the
Now you can run WordPress by installing locally.
- Make sure that the mysql server is running at localhost:3306 (if not, run
- Change directories to the sample integration service source directory.
php -f scripts/test_database_connection.php
- If the command prints
Connected successfully, php and mysql are working.
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/ ].
- Get the latest WordPress source code from https://wordpress.org/download/ and unzip it.
- Change directories to the unzipped WordPress directory (where wp-login.php is located).
php -S 127.0.0.1:25789to start the WordPress server (the port number can be replaced by any unbound port on the machine).
- 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.
- Open your local WordPress in a browser.
- Log in as
admin/123456or the username and password set up during WordPress config.
- Navigate to Plugins/Add New.
- Search for WordPress REST API (Version 2) .
- Install the WP REST API plugin.
- Activate the WP REST API plugin.
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 .
- Navigate to [ https://github.com/WP-API/Basic-Auth ].
- Click "Clone or download".
- Click Download zip and save file locally.
- In WordPress, navigate to Plugins/Add New.
- Click Upload Plugin.
- Choose the file you downloaded previously.
- Install the JSON Basic Authentication plugin.
- Activate the JSON Basic Authentication plugin.
- 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.
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.