/server

Primary LanguageJavaScriptGNU General Public License v2.0GPL-2.0

Build Status

The XIMERA Project

LaTeX to online interactive materials.

To set up a server on arch, one can as root

pacman -S nodejs npm git mongodb nginx redis
systemctl enable mongodb
systemctl start mongodb
systemctl enable nginx
systemctl start nginx
systemctl enable redis
systemctl start redis

and then as a regular user

git clone https://github.com/XimeraProject/server.git
cd server
npm install

To quickly set up a server using Ubuntu Linux 16.04 LTS (which is availble on AWS and a t2.small is sufficient), you can:

sudo apt-get install nginx mongodb libcurl4-gnutls-dev libgit2-dev
curl -sL https://deb.nodesource.com/setup_7.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo ln /usr/bin/nodejs /usr/bin/node
git clone https://github.com/XimeraProject/server.git
cd server
npm install
BUILD_ONLY=true npm install nodegit

Setting up a server

If you want to install it on Windows, set 'Setting up a server on Windows' below.

  1. Install g++, nodejs and mongodb on your computer (under Debian, may also need nodejs-legacy package)

  2. Run an instance of mongo server:

     mongod --dbpath <insert-your-path>
    

You may have to make the path. For example,

    mkdir -p /tmp/data/db
    mongod --dbpath /tmp/data/db
  1. Fetch and unpack the sample database Unpack the tarball:

     tar xfzv database.tar.gz
    

This creates a directory containing BSON and JSON files

  1. Import the database into mongo:

     mongorestore <path-to-db-directory-with-BSON-files>
    
  2. Clone the repository:

     git clone https://github.com/kisonecat/ximera
    
  3. Create file .env with content:

     XIMERA_MONGO_URL=127.0.0.1
     XIMERA_MONGO_DATABASE=test
     XIMERA_COOKIE_SECRET=thisismysecretcookieyoushouldchangethis
     COURSERA_CONSUMER_KEY=thisisacourserakey
     COURSERA_CONSUMER_SECRET=courserasecretkey
     LTI_KEY=myltikey
     LTI_SECRET=myltisecret
     GITHUB_WEBHOOK_SECRET=githubwebhooksecret
    

This file will be loaded by the dotenv package.

Note that if you used a different database name, you should set XIMERA_MONGO_DATABASE to the name of your database.

  1. Go into the ximera directory within the kisonecat repository and use npm to install all other js scripts needed by the server

     cd <path-to-ximera>
     npm install (you may be required to answer a prompt or two)
     openssl genrsa -out private_key.pem 2048
    

If you are having trouble installing the canvas package and are on a Debian-based distribution, you can try sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev

You should run gulp with the following commands

    node ./node_modules/bower/bin/bower install
    npm install
    cd ../..
    mkdir -p components/syntaxhighlighter/amd
    node node_modules/requirejs/bin/r.js -convert components/syntaxhighlighter/scripts components/syntaxhighlighter/amd
  1. Run the ximera server apps.js using:

     node app.js
    
  2. View the ximera server in your web browser at localhost:3000

Setting up a server on Windows

Before we get started, I must inform that I implemented a portable version of the server. You may need to make minor variations to the environment variables if you install it formally (meaning into the Windows registry).

  1. Download the necessary programs.

    1. Download nodejs. I downloaded the Windows binary (.exe) version into my working directory. Choose 32-bit or 64-bit based on your system.
    2. Download mongodb. I downloaded the zip version portable version and decompressed it into a subfolder of my working directory, rather than the msi installer.
    3. Download the most recent version of npm and decompress it.
    4. Download the sample database. It will be a .tar.gz file. You will need to decompress it. I good utility to use is 7zip. This will create a folder called test which should contain a bunch of .BSON and .JSON files.
  2. Clone the ximera server repository by running git clone https://github.com/kisonecat/ximera in the command prompt in your working directory. An easy way to get to the command prompt from the windows file explorer is to hold down Shift and right click on the folder and select 'Open command window here'.

  3. Make a batchfile with the following lines.

     :: change to wherever node.exe resides.  Use %~dp0 for the path of the location of this batch file.
     SET NodejsPath=%~dp0
     :: change to whereever npm.cmd resides.
     SET NPMPath=%~dp0
     :: This is the folder where the mongod.exe file lives, within the mongdb directory.  %~dp0 heads it off because it is a subfolder of %~dp0.
     SET MongoDBPath=%~dp0mongodb-win32-x86_64-2008plus-2.6.3\bin
     :: Implement these into the system path, for this session.
     SET Path=%path%%NodejsPath%;%NPMPath%;%MongoDBPath%
     SET XIMERA_MONGO_URL=127.0.0.1
     SET XIMERA_MONGO_DATABASE=test
     SET XIMERA_COOKIE_SECRET=thisismysecretcookieyoushouldchangethis
     SET COURSERA_CONSUMER_KEY=thisisacourserakey
     SET COURSERA_CONSUMER_SECRET=courserasecretkey
     SET LTI_KEY=myltikey
     SET LTI_SECRET=myltisecret
     SET GITHUB_WEBHOOK_SECRET=githubwebhooksecret
    
  4. Open the command window and run the following commands

    1. Run the batch file you created typing in the name of the batch file.
    2. Change to the ximera server folder: cd ximera
    3. Run npm install to install all the other js scripts needed by the server. This will take a while. I get the error line: npm ERR! not ok code 0. Just ignore it.
    4. Run an instance of mongo as by running: mongod --dbpath . (dont forget the period)
  5. Without closing that command window, open another one

    1. Run the batch file again.
    2. Import the test database into mongo by running: mongorestore ./test/, changing the path appropriately. The Windows UAC will pop up. You will need administrator access to bypass it.
    3. Change to the ximera server folder: cd ximera
    4. Run app.js: node app.js. You will have another UAC pop up asking whether to give node public network access.
  6. Open the browser and type in localhost:3000 into the command line and you should get this:

The css files are missing (if you noticed, after you opened your browser, in the command window you got the error LESS file error : 'bootstrap.less' wasn't found )