What do I need to do to setup KennethWare 2.0 for my Canvas instance?

Many thanks go out to Kenneth Larsen and the CIDI team at Utah State University, who built a fantastic Canvas Template Engine that make course creation a breeze! However, there are many moving parts to get KennethWare 2.0 working inside of your Canvas instance. In an effort to make the installation easier for the Canvas community, I created this general discussion and process guide.

People Needs:

A Canvas Administrator.

A Systems Admin (or some really clever person who can create and manage a Web Server).

Someone who can use and has access to an Image Manipulation tool.

Someone who is comfortable coding and making edits to PHP, JavaScript and XML files.

Note: Other than the setup and IP provisioning on our Windows Server, I did the rest of the configuration, coding, and graphic asset development. Please feel free comment on this discussion if you get stuck or have questions! I will do my best to address any issues that come up.

Software Needs

KennethWare 2.0 needs a Server! There are lots of options here:

You can use a Hosted Server service or Internally Managed Server

Picking the Server Operating System comes down to Windows Server, Linux, Mac OSX Server. From there it deciding the version or distribution.

Configuring the Web Server. You can pick IIS (Windows) or Apache (Can be used on any Server Operating System)

The Web Server needs to have PHP enabled and MySQL installed and enabled. *While you’re at it, you may want to enable Python, since there are many Python Canvas scripts!

The Web Server needs to have a IP Address (Example: 10.0.0.1) and a Domain Address (Example: https://mydomain.com/) that are Public.

HTTPS needs to be enabled and you will need a Digital Certificate.

IIS and Apache can create a Self-Signed Certificate (free!) or you can buy one from a Certificate Authority Provider like DigiCert.com

PHP, MySQL, and cURL must be enabled on the web server

Important Note: I strongly advise you to NOT use a prepackaged “WAMP Stack”. WAMPServer, Bitnami, XAMPP, are excellent for Desktop Operating like Windows 10 for creating a code testing environment. They are not recommended for a “Production” Web Server. Proceed at your own risk with this route!

A Code Editor. KennethWare 2.0 uses PHP and XML files.

Adobe makes a really good, free(!) Code Editor called Brackets.io that works on Windows, Apple OSX. There’s a Linux version in development.

There are also many Browser extensions for Web Development and Coding for Chrome and Firefox users.

An Image Manipulation tool. There are JPEGs, GIFs, and PNGs that will need to be modified if you want to make the banner images and banner thumbnails.

Again, many options to pick from like Adobe Photoshop, Adobe Fireworks, GIMP, etc.

Server Setup

Most of our processes came from the article “How to manually install Apache, PHP and MySQL on Windows?” from SuperUser.com. If you opt for Linux or Mac OSX Server, these tools are very easy to install and configure. We were more comfortable with Windows Servers based on our team’s experience.

Windows and Apache Setup

We started with a Windows Server 2008 R2 that was assigned a Public IP address.

We downloaded and extracted the Apache24folder to the root of the hard drive with a path of C:\Apache24\.

We opened a command line window (Windows+R and type cmdthen press Enter), change directory into C:\Apache24\binand run httpd.exe, normally it shouldn't print any errors.

If you get an error dialog stating that MSVCR110.dllis missing on your system, you'll need to install the Visual C++ Redistributable for Visual Studio 2012 - as always, when prompted, select the appropriate bit-version : vcredist_x86.exefor 32-Bit systems and vcredist_x64.exefor 64-Bit ones.

A warning like Could not reliably determine the server's fully qualified domain namecan be ignored for now.

Windows Firewall may prompt you to allow Apache to communicate on specific networks, I recommend you use the default settings : allow it on home and work networks, but not on public/untrusted networks.

Then, we opened a browser (Google Chrome) and browsed http://localhost, we saw a page saying It works ! which meant our Apache installation was working.

Note: If you got a warning about not being able to determine the system's fully qualified domain name, fix it by editing C:\Apache24\conf\httpd.confand editing the ServerNamevariable (it should be already there in a comment, just uncomment it and change it) :

Replace<yourhostname>with either the system's host name orlocalhost.

10. Finally, if you want to run the server automatically when the system starts (even if nobody logs in), you'll need to run it as a service - in a new elevated (as an administrator) command prompt, type :

ServerName <yourhostname>httpd.exe -k install

11. That's it, now you have a new service in Services (Windows+R then type "services.msc" then press Enter) named "Apache24" that you can control just like any other Windows service.

PHP

We downloaded the latest PHP binaries (PHP 7.0.3) from the official PHP for Windows download page. Choose the thread-safe version that matches your Apache installation's bit-version (x86 for 32-Bit, x64 for 64-Bit).

We created an empty PHP folder at the root of the hard drive, and extracted the previously downloaded archive there. You should have a path like C:\PHP\

In C:\PHP, we renamed the php.ini-production to php.ini.

We opened that php.inifile, search for extension_dir = "ext"and uncommented that line (remove the first ;). This sets the default extension dir to ext(which resolves to C:\PHP\extand avoids having to prepend ext/to all extension's paths manually like in previous versions of this post.

We then configured Apache to use that PHP, by editing C:\Apache24\conf\httpd.conf- after all the LoadModulelines, add the following :

We started Apache manually by opening a command prompt in C:\Apache24\binand running httpd.exe- If you see no errors, it means your configuration file is valid and PHP is most likely working.

You can test your PHP installation by creating a file like info.phpwith <?php phpinfo();inside and going to http://localhost/info.php- you should see quite a bit of info about your system and your PHP installation and all its modules. If you get something else like an "Internal server error" that means something's wrong.

You can now kill your current Apache process (Ctrl+C in the console) and start the service - the following part doesn't interact with Apache and can be done with the server already started.

If you want to access your MySQL database from PHP, you'll need to enable extensions that allow you to do so, like php_mysqli or php_pdo_mysql - I recommend enabling them both.

10. Open PHP's configuration file C:\PHP\php.ini in your text editor and search for php_mysqli or php_pdo_mysql - they should already be there, uncomment them.

11. Done, now you can access any MySQL database using either mysqli or PDO.

MySQL

We used MySQL Community Server 5.7.12- it was the latest version when this answer was last updated (look at the edit date at the bottom of the post).

The installer will automatically install the appropriate version (32-Bit or 64-Bit) depending on your system, even though MySQL's bit version doesn't have to match Apache's and PHP's one but it's still beneficial to use the 64-bit version of your system supports it to take advantage of more than3 GB of RAM, that's quite important as database servers tend to use a lot of RAM.

We followed the steps in the installer, if you're installing this for development then the Developer defaultwill be your best option, it'll also install MySQL Workbench which is a native GUI client, thus avoiding you having to install slow web-based tools such as PHPMyAdmin if you aren't comfortable with using the command line client.

Once everything is installed the installer will ask you for some basic configuration values, I recommend disabling "Open firewall port for network access" unless you want to access the database from another machine on the network.

We set the root password - if it's only for development purposes and your firewall blocks incoming connections from the network then a strong password isn't necessary.

Finally, you can disable the useless MySQL Notifier by right-clicking the tray icon, going into Actions -> Options, then untick the Run at Windows Startup checkbox and apply. That'll save you a few MBs of RAM and avoid slowing your machine down when it's booting.

And that's it, you now have a fully functional WAMP server that runs as a service and doesn't depend on any user (accessible even if no one is logged in).

Setting up HTTPS on a Windows Server:

We created a self-signed SSL Certificate using OpenSSL

2. We then opened the command prompt and cd to your Apache installations "bin" directory. Usually it would be:

cd "C:\Apache24\bin"

3. We created the SSL certificate we will need the openssl.cnf files location but the default location set by OpenSSL for this file is setup according to a Linux distribution, so we needed to fix it for Windows.

4. We setup the Windows environment variable OPENSSL_CONF to point to the openssl.cnf files location. It is usually located in "C:\ Apache24\conf\openssl.cnf" directory.

5. So we can set it up by the following command or through the GUI interface:

6. set OPENSSL_CONF=C:\ Apache24\conf\openssl.cnf

7. All files generated from the following commands will reside in "C:\ Apache24\bin" folder.

8. Now that we had the environment variable set we need to create a new OpenSSL certificate request using the following command:

openssl req -new -out server.csr

9. It will ask you some questions and you can safely ignore them and just answer the following questions: PEM pass phrase: Password associated with the private key you’re generating (anything of your choice). Common Name: The fully-qualified domain name associated with this certificate (i.e. www.your-domain.com).

10. Now we needed to remove the passphrase from the private key. The file "server.key" was created from the following command should be only readable by the Apache server and the administrator. You should also delete the .rnd file because it contains the entropy information for creating the key and could be used for cryptographic attacks against your private key.

openssl rsa -in privkey.pem -out server.key

11. We needed to set up an expiration date. This could be any time of your choice, we used a limit of 365 days below:

7. Make sure that "SSLCertificateFile" and "SSLCertificateKeyFile" are properly located.

8. For better organization, you can also put the whole <VirtualHost></VirtualHost> section in the "C:\ Apache24\conf\extra\httpd-vhosts.conf" along with your other Virtual Host settings there but you need to uncomment “Include conf/extra/httpd-vhosts.conf” in your conf\httpd.conf file to use that format.

Opening SSL/HTTPS port on Windows:

1. Now we need to open an exception in Windows Firewall for TCP port 443. You can do that by going to “Windows Firewall” settings in Control Panel and adding a port in the exception section.

2. We restarted the server and everything worked!

Getting PHP CURL to Call HTTPS URLs on Windows:

We ran into a snag with using PHP CURL, but the Community helped us out! Here’s what we did to fix the issue.

5. We took Developer Keys ID and Key and copied it to a safe place that could copied and pasted later. The ID and Key values are going to be copied into the config.php into $client_id = and $clientSecret = fields.

6. We added the code from canvasGlobal.js and canvasGlobal.css to our global Javascript and CSS files on our Canvas instance.

7. We saved a copy the config-example.php to config.php and modified the following code: