Installing WITM

The client (computer on which you will access Mathematica) has no special requirements. There is no software to install on the client. A default installation of Windows, Linux or most other operating systems will include a suitable browser. Even an hp iPAQ PDA works fine.

The web server, which runs Mathematica requires more work to configure.

  1. Download the WITM sources (all PHP) from http://sourceforge.net/projects/witm/
  2. Decompress the .tar.gz file. (If you don't know how to do this, give up now).
  3. Make sure you understand the security and license issues with the use of WITM.
  4. Ensure that the system requirements are met - in particular the web server must be configured to serve PHP pages. The installation of PHP is covered on the PHP web site.
  5. Configure the web server to password protect a directory. How this is done depends on the web server. For Apache at least, there is information on password protecting directories on the Apache web site.
  6. Edit witm.php to configure it for your system. You may need to edit the following parameters
    Parameter Purpose Default Value
    $math The path & switches to the command line front end 'math' /usr/local/bin/math -batchinput -batchoutput
    $demoURL A URL on which WITM will run and not expect to find a Mathematica kernel. It will then print useful help messages when one tries to do things like delete the image. www.sourceforge.net
    $demoSite A web site on which WITM will print useful help messages when one tries to do things like delete the image. Sourceforge
    $maxtime The maximum time in seconds Mathematica will run for. It is passed as the second argument to TimeConstrained[expr,t] 500
    $maxmemory The maximum memory in Mb Mathematica will use. It is passed as the second argument to MemoryConstrained[expr,1024*1024*$maxmemory] 200
    $sedcommand A command which will strip off some lines from the top of the output from Mathematica so only useful information is shown. The default is to strip one line, but this has only been tested on Solaris. On another system, it might be necessary to change the 1 to a 2 or even larger integer. sed '1d'
    $DeleteLines The number of lines on the standard output of Mathematica which are ignored. You may need to adjust this for different Mathemaitca version. 1
    $WidthOfGraphic Horizontal width in pixels of images created by Export[] for typical computers 600
    $WidthOfGraphicMobile Horizontal width in pixels of images created by Export[] for handheld computers. Adjust this to suite your PDA or similar if you have one. It's also pointless making these larger than the screen width, since it will cause you to need to scroll, although of course you can get more detail in higher resolution images. It is best to make $WidthOfGraphicMobile a little under the screen width, as not all of the screen is usually usable by an application. 210
  7. Copy your modified version of witm.php to the web server
  8. Optionally make a link from witm.php to witm.phps
    $ ln witm.php witm.phps
    This will allows the web server to highlight the code.
  9. Change the permissions on all the files so they are readable, but not writeable by the web server owner - but the src directory must be writeable by the owner for the web server, since the web server will certainly create, delete a couple of image files in the src directory.
  10. Go to the website where you installed WITM and open witm.php. If you see just text, which starts like this:
    
    // Give the path to Mathematica, or 'cat' for test purposes
    $math="/usr/local/bin/math -batchinput -batchoutput";
    
    // Since Mathematica commands can be time and memory intensive, we
    // put some limits here to make it usable. 
    
    $maxmemory=100; // Maximum RAM in bytes
    $maxtime=100; // Maximum time in seconds
    
    then the PHP page is not being served correctly.
  11. Test the page with a valid Mathematica command that does not need any graphics. Start with 5+8, press Evaluate and you should see the result fairly quickly returned.
  12. Test WITM with a Mathematica command that uses Graphics. Plot[x,{x,0,10}] will be OK for testing. If this does not work, but the simpler 5+8 worked, then it is most likely that the web server is unable to connect to a DISPLAY. Look in the Log files for your web server. If you see something like this.
    xset:  unable to open display "localhost:11.0"
    Xlib: connection to "localhost:11.0" refused by server
    Xlib: No protocol specified
    
    xset:  unable to open display "localhost:11.0"
    Xlib: connection to "localhost:11.0" refused by server
    Xlib: No protocol specified
    
    Can't open display
    Xlib: connection to "localhost:11.0" refused by server
    Xlib: No protocol specified
    
    then that is the problem, and you need to go on to the next step.
  13. Now a difficult bit - which you can omit to start with, but you will need to do this in order to produce graphical results.

    When producing graphical output, Mathematica insists on connecting to an X-server. It does not actually need one, but still insists on one. Therefore we must provide a virtual framebuffer X server. It is an X server that does not actually display anything, which permits you to run X applications (i.e. Mathematica in this case) without actually having to cope with the X graphics. It is necessary to start a virtual X server, which will listen on a DISPLAY.

    The program Xvfb, which is part of XFree86, and comes with Solaris (for example as /usr/openwin/bin/Xvfb) can do this task. I found no need to start this as the user who the runs the web server (nobody for Apache unless changed from the default) but there might be some need for that on some platforms. All I needed to do was add the following 3 lines in the startup script for Apache

    /usr/openwin/bin/Xvfb :15 &
    DISPLAY=localhost:15
    export DISPLAY
    
    The actual number does not matter much, but I would not use 0.
  14. Test WITM again with a Mathematica command that uses Graphics - Plot[x,{x,0,12}] will do fine. It is about the simplest you can use. If there are problems, you will need to resolve the X authentication problems.
  15. test with some invalid Mathematica commands. Syntax errors will often be displayed with some text about memory and time usage, something like this.
    Syntax::sntxf: "TimeConstrained[ MemoryConstrained[    
    " cannot be followed by "^".
    
    
    This is because all commands you type are wrapped inside the Mathematica functions TimeConstrained & MemoryConstrained, which prevents excessive resources (memory and CPU time) being used. The values of these are set by the parameters $maxmemory and $maxtime.



SourceForge.net Logo Valid HTML 4.01 Valid CSS!