Help Guide
Table of Contents

Director Help Guide


Have a suggestion? Found a bug? Give feedback here!

Getting Started

You will need to login using Ion in order to use Director.

If you are a student, you have the opportunity to create a personal website in the format https://user.tjhsst.edu/<username>. Students can do this by pressing the Create Webdocs button located to the upper right of the page.

If you would like to create or gain access to a website for a club or school activity, click on the Create Site button in the upper right corner.

If you would like to create a website for another purpose, contact sysadmins@tjhsst.edu.

The dashboard contains a list of sites that you have access to. You can click a particular site to see more details about it. You can use the search bar on the top of the page to filter the list of sites. Below are a few examples of search queries:

Site Editing

After you have clicked a site, you will see information about the site and options to modify it.

To upload files to your website, you can use a tool like WinSCP or FileZilla to connect to remote.tjhsst.edu. You will then need to change directories to the location specified on the left side of the page.

You can also use the online editor or web terminal to edit your site. You can access these features through the Online Editor and Web Terminal buttons on the left side of the page.

You can install Wordpress, a website creation tool, by clicking the Install Wordpress button.

Special Locations

The public folder is where the server will serve files from (in static and PHP sites). As a good first step, you will probably want to make a public/index.html file.

The private folder is where logs are generated (ex: the PHP and supervisor error logs).

If you create a .secure file in a folder, that folder will be only accessible to you after a login. If you add a .index file to a folder, the folder will list all of its contents when you navigate to it.

Custom Domains

You can use a custom domain for your site by clicking on Configure Site and adding your domain to the domain field. You will then need to set up a CNAME record to point your domain to sites.tjhsst.edu.

Project sites will be created with a subdomain under the sites.tjhsst.edu domain.

GitHub Integration

You can set up a webhook that automatically deploys code to your website after you push a commit. In order to do so, clone your repository into the public folder and follow the instructions to the right of the site page.

PHP

You can use PHP by changing your site type to PHP. To change the site type, go to the site page of the site you want to edit and click Configure Site.

Databases
The mysql_connect() functions were depreciated in PHP 5.5 and is no longer available in PHP 7. Instead, you want to use either mysqli_connect() or PDO_MySQL. The example below demonstrates how to use PDO to connect to the database.

You can create a PostgreSQL or MySQL database for a site by going to the site page and clicking the Create Database button on the right of the page. Below is some example code on how to connect to the database with PHP:

<?php
$db_opts = parse_url(getenv("DATABASE_URL"));
$dsn = ($db_opts["scheme"] == "postgres" ? "pgsql" : "mysql");
$dsn .= ":host=" . $db_opts["host"] . ";dbname=" . ltrim($db_opts["path"], "/");
$db = new PDO($dsn, $db_opts["user"], $db_opts["pass"]);

$db->exec("CREATE TABLE IF NOT EXISTS test (info TEXT)");
$db->exec("INSERT INTO test (info) VALUES ('testing')");

$stmt = $db->query("SELECT info FROM test");
while ($row = $stmt->fetch()) {
    echo $row["info"] . "<br />";
}
Errors

For security reasons, PHP error messages are not shown directly on the page, but instead logged to private/php.error.log. If you would like to display PHP errors on a page for debugging reasons, you can add the following code to the beginning of your PHP code:

error_reporting(E_ALL);
ini_set('display_errors', 1);
Dynamic Sites

To use a custom server, such as Django or Node.js, you will have to change your site type to Dynamic. You will then need to create a script file in any directory and set the Director process to this script file (click on the process on the site page to change the process). The following environment variables are available for your use:

Node.js Server

Put the following file in the public folder and name it server.js.

public/server.js
var http = require('http');

var server = http.createServer(function(req, res) {
    res.end("It works! Path: " + req.url);
});

server.listen(process.env.PORT, function() {
    console.log("Server listening on: " + process.env.PORT);
});

Put the run.sh file in the root directory, use chmod +x run.sh to mark it as executable, and set the Director process to this script file.

run.sh
#!/bin/sh

node server.js
Installing Packages

You can use the npm install <package> command to install Node.js packages. You should execute this command in the same folder as your server. A node_modules folder will be created to store these libraries.

Django Server

Run django-admin startproject server in the public folder.

Put the run.sh file in the root directory, use chmod +x run.sh to mark it as executable, and set the Director process to this script file.

run.sh
#!/bin/bash

cd server
gunicorn server.wsgi -b 127.0.0.1:$PORT -w=4
Installing Packages

To install additional python packages, you will want to create a virtual environment. The terminal commands necessary to do this are listed below:

virtualenv --python python3 venv
source venv/bin/activate

You will then be able to install packages using pip install <package>. An example is shown below:

pip install requests

Note: In order for the server to load these packages, you will need to add the line source venv/bin/activate to the run.sh file before the line where the server is started.

Flask Server

Put the following file in the public folder and name it server.py.

public/server.py
from flask import Flask
app = Flask(__name__)

@app.route("/")
def index():
    return "Hello World!"

Put the run.sh file in the root directory, use chmod +x run.sh to mark it as executable, and set the Director process to this script file.

run.sh
#!/bin/bash

gunicorn server:app -b 127.0.0.1:$PORT -w=4
Resource Limits

Server processes will run under the following limitations:

If you need more resources, contact a sysadmin.

Virtual Machines
Virtual machines currently only support IPv6. You may not be able to access sites that exclusively support IPv4 inside the virtual machine.

In some cases, your web application may use software or features that require administrative access. In these cases, you might want to create a virtual machine, which will give you an environment where you have complete control. You can view and create virtual machines by clicking on your name in the top right corner and selecting Virtual Machines. You can create a new virtual machine by clicking on Create VM.

You can also request software to be installed on the web server by using the feedback form.

Online Editor

You can use the online editor by clicking on the Online Editor button on the site page of the site you want to edit.

General Drag and Drop Utilities

The online editor has several built-in utilities for your convenience. These are generally accessible through the context menu by right clicking the blank space in the Files tab.

Keyboard Shortcuts

Your editor layout will automatically save if you make any changes. Any settings that are changed will be automatically applied and changed. Layout and settings information is saved locally on a per site basis.

If you open a preview panel, it will automatically refresh when you edit the associated file in the editor.

The Nginx tab is not editable for security reasons. If you want to make a change, ask a sysadmin.