https://webwork.maa.org/mediawiki_new/api.php?action=feedcontributions&user=Aftermath&feedformat=atomWeBWorK_wiki - User contributions [en]2024-03-29T08:20:24ZUser contributionsMediaWiki 1.34.0https://webwork.maa.org/mediawiki_new/index.php?title=Installation_Manual_for_2.4_on_Ubuntu_8.04&diff=3272Installation Manual for 2.4 on Ubuntu 8.042008-07-26T04:16:21Z<p>Aftermath: </p>
<hr />
<div>These instructions cover the installation of the Ubuntu Linux 8.04 operating system and WeBWorK 2.4 from scratch. <br />
<br />
They are more detailed (but offer fewer choices and often less background information) than the general [[Installation Manual for 2.4]] and are aimed at non unix experts. Readers may want to quickly scan [[Installation Manual for 2.4]] to get an overview of the installation process and then carefully read and follow these instructions.<br />
<br />
== Notation ==<br />
<br />
First some short comments on notation we will be using. We will use <code>&lt;key&gt;</code> to indicate that you should press a specific key (e.g. <code>&lt;Enter&gt;</code>, <code>&lt;Tab&gt;</code>, <code>&lt;F12&gt;</code>, etc.). Sometimes we will also use e.g. <code>&lt;root password&gt;</code> to indicate you have to enter the root password.<br />
<br />
<code>^</code> will indicate the <code>&lt;Ctrl&gt;</code> key so e.g. <code>^X</code> is really shorthand for <code>&lt;Ctrl&gt; &lt;X&gt;</code>, i.e. press the Ctrl key and hit the X key.<br />
<br />
We will give references to specific versions of software, e.g. httpd-2.2.4.tar.gz rather than the more general httpd-2.x.x.tar.gz. In most cases you should be able to use the latest stable version but we have only tested the versions listed.<br />
<br />
== Installing the Ubuntu 8.04 Linux Operating System ==<br />
<br />
===Installation CD ===<br />
Obtain the <code>Desktop Edition, Alternate</code> installation DVD/CD set. Connect to http://www.ubuntu.com/ for information. On the download page http://www.ubuntu.com/getubuntu/download make sure you check the box for <code>Check here if you need the alternate desktop CD. This CD does not include the Live CD, instead it uses a text-based installer</code>. For example you can use wxDownload Fast or BitTorrent to download an ISO image of the installation CD and then burn your own installation CD. If you download the ISO image, make sure that you verify the integrity of the downloaded file by comparing the MD5 checksum of the downloaded file with the MD5 checksum listed at https://help.ubuntu.com/community/UbuntuHashes or at the download site (e.g. http://mirrors.kernel.org/ubuntu-releases/7.04/MD5SUMS). wxDownload Fast automatically calculates the MD5 checksums which is convenient. I have had good luck downloading from mirrors.kernel.org but your experience may differ. These instructions will assume you have the installation CD but installing from a commercial DVD/CD set or from the net should be essentially identical.<br />
<br />
Place the installation CD in your DVD/CD drive and reboot your computer from the DVD drive. You may have to press <code>&lt;F12&gt;</code> during the boot process to bring up a boot menu which will allow you to select booting from the DVD. Or you many have to edit the BIOS to select the DVD as the first boot device.<br />
<br />
First select <code>English</code> by just hitting <code>&lt;Enter&gt;</code>.<br />
<br />
You will see a list of options. <br />
<br />
# If you want hit <code>&lt;F1&gt;</code> to obtain help and see additional boot methods<br />
# You can just hit <code>&lt;Enter&gt;</code> to accept the default install method except in the following situation<br />
# If your network has DHCP enabled but you want to setup your server with a static IP address, then hit <code>&lt;F6&gt;</code> and on the <code>Boot OPtions</code> line move the cursor before <code>quiet --</code> and type <code>netcfg/disable_dhcp=true</code> , leave a space before <code>quiet</code> and then hit <code>&lt;Enter&gt;</code><br />
# A succession of pages follow, for each select the obvious option and hit <code>&lt;Enter&gt;</code>. For example my obvious options are <code>English</code>, <code>United States</code>, <code>&lt;No&gt;</code>, <code>USA</code> and <code>USA</code> <br />
# The system will than scan your CD and load various components<br />
# If your system has multiple network interfaces, you will be asked to select the one to be used during the installation (which will usually be a hard wired ethernet connection)<br />
# Unless you entered the <code>netcfg/disable_dhcp=true</code> boot option above, the system will try to configure your network using DHCP. If you have DHCP, your network interface will be set up automatically. If you don't have DHCP, automatic network configuration will fail quickly (or just hit <code>&lt;Enter&gt;</code> to <code>Cancel</code> if you are impatient). Then hit <code>&lt;Enter&gt;</code> to <code>Continue</code><br />
<br />
'''Manual network configuration'''. If your network interface was set up automatically by DHCP, you can skip the rest of this paragraph. Otherwise you will have to enter your machine's static ip address, etc. To do this<br />
# Select <code>Configure network manually</code><br />
# Enter your computer's IP address and use <code>&lt;Tab&gt;</code> to select <code>Continue</code><br />
# The <code>netask</code> is probably OK as it but another possibility may be 255.255.0.0<br />
# Enter the ip address of your gateway router. Ubuntu makes a good guess at this, but your network may be set up differently.<br />
# Next enter the ip address(es) of up to 3 nameservers separated by spaces (at a minimum you have to enter the ip address one nameserver)<br />
# Enter the name of your server<br />
# Enter the domain name for the domain your server sits on (e.g. math.myschool.edu)<br />
# This completes the static ip address setup<br />
<br />
Now select your time zone and wait for the clock to be configured<br />
<br />
===Optional Configurations===<br />
<br />
If you will have a large number of users (say over a 1,000) and/or a slow server, you may want to consider the first two optimizations. They are independent but related and deal with how WeBWorK handles various temporary and static files. We call these two options '''Optional A''' and '''Optional B'''. The third option, '''Optional C''', gives greater security.<br />
<br />
'''Optional A''' creates a separate partition on which are stored all of WeBWorK's "temporary" files. These are mostly small files such as png images of equations, pdf files, etc that may be reused but if they are not present (e.g. if they get deleted) they will be seamlessly regenerated on the fly. There is no reason to back up such files and having them in a separate partition means that it is easier and faster to back up other partitions and skip backing up unnecessary files.<br />
<br />
'''Optional B''' installs and configures a lightweight webserver. Apache is a very standard and powerful webserver which we use to serve WeBWorK pages. However its child processes use a lot of resources (e.g. memory). When serving static files and images, a much lighter weight webserver can be used. This can substantially reduce the load on a heavily used server.<br />
<br />
'''Optional C''' configures Apache so that access to WeBWorK will be through an encrypted Secure Sockets Layer (SSL) with an https: URL.<br />
<br />
Except for creating a separate partition, we will wait until WeBWorK is installed and tested before implementing these options. We mention them here because the next step is partitioning the disks.<br />
<br />
===Partition disks===<br />
Next comes the <code>Partition disks</code> pages. You should be able to accept the defaults unless you want to follow '''Optional A''' and/or create separate partitions for various directories. There is a lot of information on the web if you don't want to accept the default partition set up. If you want to implement '''Optional A''' follow the directions below. <br />
<br />
'''Optional A''': The default partitioning scheme creates just two partitions, a root (<code>/</code>) partition and a swap partition. Here we will create those and an additional partition for WeBWorK's temporary files.<br />
<br />
# On the <code>Partition disks</code> page use <code>&lt;Tab&gt;</code> to select <code>Go Back</code> and then select <code>Partition disks</code> <br />
# Use the down arrow to select your disk (<code>sda</code>)<br />
# On the <code>You have selected an entire device to partition...</code> page select <code>Yes</code> to the question <code>Create new empty partition table on this device</code><br />
# On the <code>This is an overview...</code> page select <code>FREE SPACE</code><br />
# On the <code>How to use this free space</code> page select <code>Create a new partition</code><br />
# Now you have to decide how to allocate your disk space. The rule of thumb is to use twice the amount of RAM you have for swap (e.g. 2 GB if you have 1 GB of RAM). For WeBWorK's temporary files 25 GB for every 1,000 students should be ample. You can allocate the remainder of your disk space to the root (<code>/</code>) partition. Actually if you are going through the trouble of doing this, you probably will want to research other partitioning recommendations.<br />
# On the <code>The maximum size you can use...</code> page enter the size for your root (<code>/</code>) partition and <code>Continue</code><br />
# Select <code>Primary</code> for the type of the new partition<br />
# Select <code>Beginning</code> for the location of the new partition<br />
# Select <code>/</code> for the Mount point of the new partition and then select <code>Done setting up the partition</code><br />
<br />
Now we repeat the process for the partition which will hold WeBWorK's temporary files.<br />
# On the <code>This is an overview...</code> page select <code>FREE SPACE</code><br />
# On the <code>How to use this free space</code> page select <code>Create a new partition</code><br />
# On the <code>The maximum size you can use...</code> page enter the size for WeBWorK's temporary files partition. As we said 25 GB for every 1,000 students should be ample. Then <code>Continue</code><br />
# Select <code>Logical</code> for the type of the new partition<br />
# Select <code>Beginning</code> for the location of the new partition<br />
# Select <code>Mount point</code> and then hit <code>&lt;Enter&gt;</code><br />
# Select <code>Enter manually</code> and then hit <code>&lt;Enter&gt;</code><br />
# For the <code>Mount point for this partition</code> enter <code>/var/www/wwtmp</code> and <code>Continue</code><br />
# Then select <code>Done setting up the partition</code><br />
<br />
Finally we set up the swap partition<br />
# On the <code>This is an overview...</code> page select <code>FREE SPACE</code><br />
# On the <code>How to use this free space</code> page select <code>Create a new partition</code><br />
# On the <code>The maximum size you can use...</code> page enter the size for swap partition. As we said the rule of thumb is to use twice the amount of RAM you have. Then <code>Continue</code><br />
# Select <code>Logical</code> for the type of the new partition<br />
# Select <code>Beginning</code> for the location of the new partition<br />
# Select <code>Use as</code> and then hit <code>&lt;Enter&gt;</code><br />
# Select <code>swap area</code> and then hit <code>&lt;Enter&gt;</code><br />
# Then select <code>Done setting up the partition</code><br />
<br />
Finally <br />
# Review your changes and<br />
# Select <code>Finish partitioning and write changes to disk</code> and then hit <code>&lt;Enter&gt;</code><br />
# Select <code>Yes</code> to confirm the changes<br />
<br />
===Base Installation===<br />
# Now the base installation takes place --- this takes a short time<br />
# Enter yourself as a user (with user name and password). Note this account will function partially as the <code>root</code> account so you might want to pick a different username and password than you regularly use. <br />
# You can probably leave the HTTP proxy information blank<br />
# Now sit back and relax while a lot of software is installed --- this takes awhile<br />
<br />
The final step is to install the boot loader. I have a non standard setup and for some reason I had trouble installing the Grub boot loader but Lilo worked fine. Almost certainly, Grub will work fine for you<br />
<br />
===Continue Installation ===<br />
After this finishes the system will eject the CD and ask you to reboot. <br />
<br />
# Log into your account <br />
# Accept any available updates. You may see a little notification icon (it has a arrow on it) to the right of your name in the upper right hand corner of the screen --- click on it. Alternately you can select <code>System</code>, <code>Administration</code>, <code>Update Manager</code>. Click <code>install Updates</code>. You may have to enter the <code>&lt;your password&gt;</code> which functions as the <code>&lt;root password&gt;</code> . Follow any instructions, e.g. you may be told to reboot as soon as the installation is completed (to reboot, select <code>System</code>, <code>Quit</code> and then <code>Restart</code>)<br />
<br />
===Test Browser and Keyboard ===<br />
<br />
After reboot and login, click on <code>Applications</code>, <code>Internet</code>, <code>Firefox Web Browser</code> (or just click the Firefox icon at the top of the screen) and you should be connected to the world. <br />
Goto <br />
http://webwork.maa.org/wiki/Installation_Manual_for_2.4_on_Ubuntu_8.04<br />
where you can view this document and, if you want, copy commands that you need (see below).<br />
<br />
If something is wrong and you are not connected to the web, the first thing to do is check that you entered the correct network information.<br />
# Select <code>System</code>, <code>Administration</code>, <code>Network</code><br />
# Click on <code>Unlock</code><br />
# Enter <code>&lt;your password&gt;</code> and click <code>Authenticate</code><br />
# Select <code>Wired connection</code> and click <code>Properties</code><br />
# Check that all the entries are correct and edit them if they are not<br />
# Then click <code>OK</code><br />
# Next click on <code>DNS</code> and check the name server entries and correct if necessary<br />
# Click on <code>Close</code> to close <code>Network settings</code><br />
Your network connection should start up almost immediately. If you are still having problems it's time to investigate further or seek help.<br />
<br />
Here's an aside on keystroke delay and repetition rate. If you are like me and find the keystroke delay too short (so that you often type "geeet" when you want to type "get"), do the following. Click <code>System</code>, <code>Preferences</code>, <code>Keyboard</code> and then increase the delay time interval and hit <code>Close</code>.<br />
<br />
== Terminal Window Notation and Use ==<br />
<br />
Before installing and configuring additional software, we need to talk about terminal windows.<br />
<br />
To open a terminal window click <code>Applications</code>, <code>Accessories</code> and then select <code>Terminal</code>.<br />
<br />
In a terminal window some commands will have to be run as root whereas<br />
others should be run as a regular user. We will use # to indicate<br />
that the command is to be run as root e.g.<br />
<br />
# perl -MCPAN -e shell<br />
<br />
and $ to indicate that the command is to be run as a normal user e.g.<br />
<br />
$ cp .bashrc .bashrc.bak1<br />
<br />
To execute the above commands you have to hit <code>&lt;Enter&gt;</code>. We'll just assume this. <br />
After executing a command, often the system will respond with text (sometimes a lot of text!) which we will usually not repeat below. We only give the commands that you should execute.<br />
<br />
The bash shell which you will be using has a number of very<br />
convenient features.<br />
<br />
One is command and file name completion. If you are typing (e.g.<br />
<code>ch</code>) and hit <code>&lt;tab&gt;</code> bash will complete the command or filename if it is<br />
unambiguous (or more precisely it will complete as much as possible).<br />
If there are multiple possibilities (as in the case of <code>ch</code>) nothing will<br />
happen (except you may hear a beep) and you can type more letter(s) and hit <code>&lt;tab&gt;</code> again. Or you can<br />
hit <code>&lt;tab&gt;</code> a second time and you will see a list of all possible<br />
completions. E.g. entering <code>ch&lt;tab&gt;&lt;tab&gt;</code> gives a list of possible<br />
completions and <code>ch&lt;tab&gt;g&lt;tab&gt;</code> (or <code>chg&lt;tab&gt;</code>) gives <code>chgrp</code>, the change group command. This<br />
is very fast and convenient and it also leads to fewer typing errors.<br />
<br />
Another useful shortcut is the command history. Using the up and down<br />
arrow keys will bring up previous commands which can be edited and then<br />
executed. If you are repeating a command or entering a command which<br />
is similar to a previous one, this is very useful.<br />
<br />
You can copy commands from these instructions (with <code>copy</code> from the Edit dropdown list or <code>^C</code>) and paste them into a terminal window<br />
(with <code>paste</code> from the Edit dropdown list or <code>&lt;Shift&gt; &lt;Ctrl&gt; &lt;V&gt;</code>). However typing yourself using command completion is probably just as fast except if a command is long.<br />
<br />
By default Ubuntu has no password set for the root user. To gain root access you have to type in your own user password. This is the password you set for the first user while installing Ubuntu. However we will<br />
manually set a password for the root user since this is a much more standard setup. To do this, type in the following in a terminal window:<br />
<br />
$ sudo passwd<br />
Password: <your password><br />
<br />
After that you are asked to type in the new root password twice. Enter the password for the root user and '''Do not forget what you enter here'''.<br />
<br />
Enter new UNIX password: <root password><br />
Retype new UNIX password: <root password><br />
passwd: Password updated successfully<br />
$<br />
<br />
To test this <br />
<br />
$ su<br />
Password: <root password><br />
# whoami<br />
root<br />
#exit<br />
$<br />
<br />
Finally perhaps a safer way to run commands as <code>root</code> is to use the <code>sudo</code> command<br />
<br />
$ sudo <command><br />
Password: <your password><br />
<br />
After you enter the password the command is executed. For a certain period (maybe 5 minutes) you can execute additional <code>sudo</code> commands without reentering <code>&lt;your password&gt;</code>. A log of all <code>sudo</code> commands is kept (I don't know where). In these instructions for the most part we will not use <code>sudo</code>, but keep it in mind for other times that you have to become <code>root</code> in order to execute a few commands (e.g. restarting <code>Apache</code>).<br />
<br />
Note that for certain GUI tools such as the <code>Synaptic Package Manager</code> that require root access, the password required is <code>&lt;your password&gt;</code>, the password for the first account you set up, not the new <code>&lt;root password&gt;</code>.<br />
<br />
For our next terminal window task create a <code>downloads</code> directory where we will keep copies of downloaded software.<br />
<br />
$ cd<br />
$ mkdir downloads<br />
<br />
==Ubuntu Software Packages ==<br />
<br />
Our next task is to install a number of Ubuntu software packages.<br />
<br />
# Select <code>System</code>, <code>Administration</code> and then <code>Synaptic Package Manager</code>. You will have to enter the <code>&lt;your password&gt;</code>. The <code>Synaptic Package Manager</code> window will open<br />
# Click on <code>Reload</code> to bring the package information up to date<br />
<br />
Now we will actually select and install a large number of packages. The process is the same for all packages. I'll give an example of installing <code>libnet-ldap-perl</code> and then just give the list of required packages.<br />
<br />
# Select <code>Search</code> <br />
# Under <code>Look in:</code> select <code>Name</code>. The default <code>Description and Name</code> sometimes returns too many possibilities<br />
# We are searching for <code>libnet-ldap-perl</code> so enter <code>ldap-perl</code> (or something similar; you can copy and paste from this document if you want) and click on <code>Search</code><br />
# This should result in 3 possibilities. Select and Mark for Installation (by double clicking or checking and then selecting <code>Mark for Installation</code>) <code>libnet-ldap-perl</code>. You will see a pop up window <code>Mark additional required changes?</code> and you should always click <code>Mark</code> to accept the requirements.<br />
# Follow this basic procedure for all the packages listed below<br />
<br />
Here is the list of Debian packages that need to be installed. See [[Installation Manual for 2.4]] for a short explanation of what most of these packages do. <br />
<br />
# <code>apache2</code><br />
# <code>apache2-mpm-prefork</code><br />
# <code>cvs</code><br />
# <code>dvipng</code><br />
# <code>gcc</code><br />
# <code>libapache2-request-perl</code><br />
# <code>libdatetime-perl</code><br />
# <code>libdbd-mysql-perl</code><br />
# <code>libemail-address-perl</code><br />
# <code>libextutils-xsbuilder-perl</code><br />
# <code>libgd-gd2-perl</code><br />
# <code>libmail-sender-perl</code><br />
# <code>libnet-ldap-perl</code><br />
# <code>libossp-uuid-perl</code><br />
# <code>libsql-abstract-perl</code><br />
# <code>libstring-shellquote-perl</code><br />
# <code>libtimedate-perl</code><br />
# <code>libxml-parser-perl</code><br />
# <code>libxml-writer-perl</code><br />
# <code>make</code><br />
# <code>mysql-server-5.0</code><br />
# <code>netpbm</code><br />
# <code>openssh-server</code><br />
# <code>preview-latex-style</code><br />
# <code>tetex-bin</code><br />
# <code>tetex-extra</code><br />
# <code>unzip</code><br />
<br />
When I do this I see on the bottom of <code>Synaptic Package Manager</code> window <code>82 to install/upgrade</code>, <code>1 to remove</code>. Your numbers may differ slightly. <br />
Now click <code>Apply</code> and <code>Apply</code> again to confirm the changes. You will be asked several times to enter a<br />
<code>New password for the MySQL "root" user</code>; just hit <code>&lt;Enter&gt;</code> which gives the default blank password. We will fix this and several other MySQL security issues below.<br />
<br />
That completes the set up of your base Ubuntu system. You can quit the <code>Synaptic Package Manager</code>.<br />
<br />
<br />
If you would prefer to install all of these packages in one fell swoop, run this command as root:<br />
<br />
<code># aptitude install apache2 apache2-mpm-prefork cvs dvipng gcc libapache2-request-perl libdatetime-perl libdbd-mysql-perl libemail-address-perl libextutils-xsbuilder-perl libgd-gd2-perl libnet-ldap-perl libossp-uuid-perl libsql-abstract-perl libnet-ldap-perl libsql-abstract-perl libstring-shellquote-perl libtimedate-perl libxml-parser-perl libxml-writer-perl make mysql-server-5.0 netpbm openssh-server preview-latex-style tetex-bin tetex-extra unzip</code><br />
<br />
== Installing Perl Modules ==<br />
We now have to install several additional Perl modules which unfortunately are not available from the Debian package system.<br />
<br />
=== Testing Perl Modules ===<br />
To test if a Perl module is installed and working on your system, issue the following command, replacing <code>Module</code> with the name of the module:<br />
<br />
$ perl -MModule -e 'print "installed!\n"'<br />
<br />
If the module is installed you will see <code>installed!</code>. If not you will see at lot of gibberish. E.g. at this stage in our installation process <code>CPAN</code> is installed and <code>MXML::Parser::EasyTree</code> is not so<br />
<br />
$ perl -MCPAN -e 'print "installed!\n"'<br />
<br />
yields<br />
<br />
installed!<br />
<br />
and<br />
<br />
$ perl -MXML::Parser::EasyTree -e 'print "installed!\n"'<br />
<br />
yields<br />
<br />
Can't locate XML/Parser/EasyTree.pm in @INC (@INC contains: <br />
/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8<br />
...<br />
<br />
=== Installing Additional Perl Modules from CPAN ===<br />
<br />
Be aware that in rare cases you might have to <br />
as root run<br />
<br />
$ su<br />
<root password><br />
# unset LANG<br />
# exit<br />
$<br />
<br />
since otherwise the installation of some modules (Module::Build is an example) may fail.<br />
<br />
First we will set up CPAN. For this you have to be root.<br />
<br />
$ su<br />
<root password><br />
# perl -MCPAN -e shell<br />
<br />
Since this is the first time you are using CPAN it will ask you <code>Are you ready for manual configuration?</code> <br />
Respond <code>no</code> and that should be it. <br />
<br />
Next we add at least one mirror and reload the index. A list of mirrors can be found at http://mirrors.cpan.org. To add the mirror ftp://mirrors.kernel.org/pub/CPAN and reload the index do the following. For me, a slow and inaccurate typist, copying (<code>^C</code>) and pasting (<code>&lt;Shift&gt; &lt;Ctrl&gt; &lt;V&gt;</code>) is much faster.<br />
<br />
cpan> o conf urllist push ftp://mirrors.kernel.org/pub/CPAN<br />
cpan> reload index<br />
<br />
Note that one time this failed when I tried to do it in the evening but when I tried again the next morning it worked fine. Now we update CPAN itself<br />
<br />
cpan> install Bundle::CPAN<br />
<br />
and always hit <code>&lt;Enter&gt;</code> to accept the defaults when prompted. This can be a long process with many long pauses. Please be patient. <br />
When you again see the <br />
<br />
cpan><br />
<br />
prompt enter<br />
<br />
cpan> reload cpan<br />
cpan> o conf commit<br />
<br />
Now install the following modules<br />
<br />
cpan> install XML::Parser::EasyTree Iterator Iterator::Util Net::IP <br />
<br />
and in case you are prompted accept all defaults by just hitting <code>&lt;Enter&gt;</code>. <br />
Note that with more than one module to install, we just list them after <code>install</code> separated by spaces.<br />
<br />
When you again see the <br />
<br />
cpan><br />
<br />
prompt enter<br />
<br />
cpan> exit<br />
#<br />
<br />
=== Installing Additional Perl Modules from Source ===<br />
At one point in time (August 2006), the installation of <code>DateTime</code> using CPAN was broken. Currently <code>DateTime</code> can be installed using CPAN. However it is useful to show you how to install perl modules from source in case one of the perl modules we installed above gets updated and its installation from CPAN becomes broken. If that happens you can follow the procedures outlined here to install the module from source. <br />
<br />
'''IMPORTANT:''' With Debian we have already installed <code>DateTime</code> so you don't have to install it as outlined below. We are just using this as an example of installing a module from source which hopefully you will never have to do. You can skip this section and go directly to the Apache 2 and mod_perl section.<br />
<br />
Now we give the example of installing <code>DateTime</code> from source. As we said you can skip this part.<br />
<br />
Goto http://search.cpan.org/,<br />
search for <code>DateTime</code> and click on <code>DateTime</code>. Then near the top right download <code>DateTime-0.36.tar.gz</code> and save it to disk. Move it to your <code>downloads</code> directory. Then<br />
<br />
$ cd <br />
$ cd downloads<br />
$ tar -zvxf DateTime-0.36.tar.gz<br />
$ cd DateTime-0.36/<br />
<br />
<br />
$ perl Makefile.PL<br />
$ make<br />
$ make test<br />
<br />
If <code>make test</code> indicates something is missing you will have to install that. In fact in the case of <code>DateTime</code>, you would see that quite a few things are missing.<br />
<code>DateTime</code> requires the additional modules <code>version</code> , <code>Module::Build</code> , <code>Class::Singleton</code> , <code>DateTime::TimeZone</code> and <code>DateTime::Locale</code> . We could install these using CPAN<br />
<br />
# perl -MCPAN -e shell<br />
cpan> install version Module::Build Class::Singleton DateTime::TimeZone DateTime::Locale<br />
cpan> exit<br />
# exit<br />
$<br />
<br />
If you see anything that looks suspicious during this process, you can always test to see if the perl module in question was in fact installed. If it was not installed<br />
try CPAN first and if CPAN fails then install it from source. The great thing about CPAN (if it works) is that it will trace down and automatically install all required components. Note that if you get a message indicating that <code>package/file.pm</code> was not found, you should serach for and install <code>package::file</code> since perl modules use a double colon (<code>::</code>) as a directory separator.<br />
<br />
Assuming all is OK<br />
<br />
$su<br />
<root password><br />
# make install<br />
# exit<br />
$<br />
<br />
Finally you should definitely test that the module (e.g. <code>DateTime</code>) was installed sucessfully<br />
<br />
$ perl -MDateTime -e 'print "installed!\n"'<br />
<br />
If you see <br />
<br />
installed!<br />
<br />
you can celebrate.<br />
<br />
== Apache 2 and mod_perl ==<br />
<br />
First we have to enable a couple Apache modules. Acting as <code>root</code> in a terminal window enter<br />
<br />
# a2enmod apreq<br />
# a2enmod info<br />
<br />
Next we make a copy of the configuration files for safekeeping. <br />
<br />
# cd /etc/apache2/mods-available<br />
# cp info.conf info.conf.bak1<br />
# cp status.conf status.conf.bak1<br />
<br />
Now we will edit configuration files <code>info.conf</code> and <code>status.conf</code> to allow us to view information about the setup and performance of the web server. Note that this is not absolutely necessary but it can be very useful. You can use your favorite editor but we will give instructions assuming you are using <code>gedit</code>. Note that you have to be root to edit these files. First we edit <code>info.conf</code><br />
<br />
# cd /etc/apache2/mods-available<br />
# gedit info.conf<br />
<br />
I suggest you allow access to server information from e.g. your department domain. To do this uncomment (i.e. remove the <code>#</code> from) <br />
# Allow from .example.com<br />
and then replace <code>.example.com</code> by <code>.math.yourschool.edu</code><br />
where of course you should edit <code>.math.yourschool.edu</code> appropriately. <br />
<br />
Then save the file and quit (<code>Save</code> and <code>File</code>, <code>Quit</code>).<br />
<br />
Now we edit <code>status.conf</code><br />
<br />
# cd /etc/apache2/mods-available<br />
# gedit status.conf<br />
<br />
After the comments at the top and above the <code><Location /server-status></code> line enter<br />
<br />
ExtendedStatus On<br />
<br />
Now edit the <br />
# Allow from .example.com<br />
line just as you did for <code>info.conf</code>.<br />
Then save the file and quit<br />
<br />
Now we have to set your server's fully qualified domain name. <br />
# Select <code>System</code>, <code>Administration</code>, <code>Network</code><br />
# Click on <code>Unlock</code><br />
# Enter <code>&lt;your password&gt;</code> and click <code>Authenticate</code><br />
# Click on <code>General</code><br />
# Under <code>Host name</code> enter <code>your_server_name</code> (if it's not already there)<br />
# Then under <code>Domain name</code> enter your server's domain name, something like <code>department.school.edu</code><br />
<br />
Next<br />
# Click on <code>Hosts</code><br />
#There should also be an entry with your server's IP address (if not you should add one)<br />
# Select the entry with your server's IP address and click <code>Properties</code><br />
# Under Aliases you should see your server's fully qualified domain name, something like <code>your_server_name.department.school.edu</code><br />
# Add or edit these entries if they are not correct<br />
# Then click <code>OK</code><br />
# And click <code>Close</code> to close <code>Network settings</code><br />
<br />
You can check these settings by running the commands<br />
<br />
$ hostname --fqdn<br />
<br />
and <br />
<br />
$ hostname<br />
<br />
The first respond with the fully qualified domain name and the second with just <code>your_server_name</code>.<br />
<br />
If the command <code>hostname --fqdn</code> returns <code>Unknown host</code> do the following:<br />
<br />
# Select <code>System</code>, <code>Administration</code>, <code>Network</code><br />
# Click on <code>Unlock</code><br />
# Enter <code>&lt;your password&gt;</code> and click <code>Authenticate</code><br />
# Click on <code>Hosts</code><br />
# Select the entry with your server's IP address and click <code>Properties</code><br />
# Under Aliases you should see your server's fully qualified domain name, something like <code>your_server_name.department.school.edu</code><br />
# Select the entry <code>127.0.0.1</code> and click <code>Properties</code><br />
# Under Aliases make sure you have the following entries in order<br />
## first your server's fully qualified domain name, something like <code>your_server_name.department.school.edu</code><br />
## second your server's name, something like <code>your_server_name</code><br />
## third <code>localhost</code><br />
# Click <code>Add</code> and add an entry with <code>IP address</code> <code>127.0.1.1</code> and under <code>Aliases</code> put your server's fully qualified domain name, something like <code>your_server_name.department.school.edu</code><br />
# Then click <code>OK</code><br />
# And click <code>Close</code> to close <code>Network settings</code><br />
<br />
Then check again by running the commands<br />
<br />
$ hostname --fqdn<br />
<br />
and <br />
<br />
$ hostname<br />
<br />
Note that if your server can not find its fully qualified domain name, certain tools (such as the Synaptic Package Manager) will not start.<br />
<br />
Now restart Apache<br />
<br />
$su<br />
<root password><br />
# apache2ctl graceful<br />
# exit<br />
$<br />
<br />
and test your server by connecting to<br />
"http://localhost/" and/or connecting to your<br />
server from a browser on a remote machine. You should see the page '''It works!''' indicating that Apache is running.<br />
<br />
You can check Apache's status by connecting to<br />
"http://localhost/server-status" using a browser on your machine or from a browser on a remote machine in the math.yourschool.edu domain.<br />
<br />
Further test Apache by connecting to<br />
"http://localhost/server-info" using a browser on your machine (or or from a browser on a remote machine in the math.yourschool.edu domain) and you will see a page listing various <br />
information about Apache. In particular under <code>Server Settings</code> you should see<br />
<br />
Server Version: Apache/2.2.8 (Ubuntu) mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/v5.8.8<br />
<br />
indicating that both <code>mod_apreq2</code> and <code>mod_perl</code> are installed.<br />
<br />
If you have problems now or in the future, a good first thing to do is to look at the Apache error log which is located at <code>/var/log/apache2/error.log</code>. In the directory <code>/var/log/apache2/</code> you can "less" through the error log (<code>less error.log</code>), look at the last few entires (<code>tail error.log</code>) or run the command <code>tail -f error.log</code> which will display new error messages as they are appended to the file. Use <br />
<code>^C</code> to break out of <code>tail -f</code> .<br />
<br />
== Checking MySQL ==<br />
<br />
First check that MySQL is running by <br />
<br />
$ mysql -u root<br />
<br />
You should see<br />
<br />
Welcome to the MySQL monitor. Commands end with ; or \g.<br />
Your MySQL connection id is 1<br />
Server version: 5.0.51a-3ubuntu5 (Ubuntu)<br />
<br />
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br />
<br />
mysql> <br />
<br />
Enter <code>exit</code> to exit<br />
<br />
mysql> exit<br />
Bye<br />
$<br />
<br />
== Reboot and Test ==<br />
<br />
Now reboot the system (<code>System</code>, <code>Quit</code>, <code>Restart</code>).<br />
<br />
Now connect to<br />
"http://localhost/" using a browser on your machine and/or to your<br />
server from a browser on a remote machine. You should see the page '''It Works''' indicating that Apache is running.<br />
<br />
This is also a good time to check that you can login your server from a remote location using SSH (non secure telnet and FTP are not allowed but secure SSH and SFTP are). If you are using "SSH Secure Shell" (now called "SSH Tectia"), a popular SSH client for PC's, you will have to add <code>Keyboard Interactive</code> to the list of "Authentication methods" under "Authentication" if it's not already there. <br />
<br />
Finally test that MySQL is running.<br />
<br />
$ mysql -u root<br />
...<br />
mysql> <br />
mysql> exit<br />
Bye<br />
$<br />
<br />
Currently the MySQL password is empty so we didn't need a password.<br />
We will take care of that now.<br />
<br />
== MySQL Security Issuses ==<br />
As initially set up, MySQL is a very open system. There are anonymous accounts with full privileges for some databases and the root accounts are not password protected. See e.g. http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html for information on this. We recommend removing the anonymous accounts and giving passwords to the root accounts. There are three root accounts, one is <code>root@localhost</code>, one is <code>root@127.0.0.1</code> and the third is <code>root@host_name</code> where <code>host_name</code> is the name of your server. To find this name, do the following <br />
<br />
$ mysql -u root<br />
mysql> SELECT Host, User, Password FROM mysql.user;<br />
<br />
You will see a table with six entries. For <code>localhost</code> you will see three Users, <code>root</code> and <code>debian-sys-maint</code> and one with an empty name (the anonymous user). The other listed Host (with a <code>root</code> user and also one with an empty name) is the name of your server which we will denote by <code>host_name</code>. <br />
<br />
First we will remove the anonymous accounts. <br />
<br />
mysql> DELETE FROM mysql.user WHERE User = <nowiki>''</nowiki>;<br />
mysql> FLUSH PRIVILEGES;<br />
<br />
Now using the up arrow key repeat the command<br />
<br />
mysql> SELECT Host, User, Password FROM mysql.user;<br />
<br />
and you should get a table with only four users (three <code>root</code> and one <code>debian-sys-maint</code>). <br />
<br />
Now we will assign a password to these <code>root</code> accounts. <br />
<br />
In the third command below, replace <code>host_name</code> with the name of the server host. In all commands replace <code>newpwd</code> with your choosen MySQL <code>root</code> password. As was said above, '''Do not forget what you enter here'''. Also remember that this is the password for the MySQL <code>root</code> user, not the Ubuntu linux system <code>root</code> user. Below we refer to this as <code>&lt;mysql root password&gt;</code><br />
<br />
mysql> UPDATE mysql.user SET password=PASSWORD('newpwd') WHERE host='localhost' and user='root';<br />
mysql> UPDATE mysql.user SET password=PASSWORD('newpwd') WHERE host='127.0.0.1' and user='root';<br />
mysql> UPDATE mysql.user SET password=PASSWORD('newpwd') WHERE host='host_name' and user='root';<br />
mysql> FLUSH PRIVILEGES;<br />
<br />
Now use your up arrow key to run the command<br />
<br />
mysql> SELECT Host, User, Password FROM mysql.user;<br />
<br />
and you should see that all three users now have passwords (which will be displayed in encrypted form).<br />
<br />
Then exit MySQL<br />
<br />
mysql> exit<br />
Bye<br />
$<br />
<br />
<br />
and test that all is well:<br />
<br />
$ sudo /etc/init.d/mysql restart<br />
password:<your password><br />
$ mysql -u root -p <br />
Enter Password: <mysql root password><br />
<br />
You should see<br />
<br />
Welcome to the MySQL monitor ...<br />
mysql><br />
<br />
Enter<br />
<br />
mysql> SELECT Host, User, Password FROM mysql.user;<br />
<br />
and you should see encrypted passwords for all three accounts. Note that the way MySQL is set up, you can only gain access to the <code>localhost</code> account, not to the <code>host_name</code> account but setting a password for the <code>host_name</code> account is a safer thing to do in case the set up gets changed. Now exit MySQL<br />
<br />
mysql> exit<br />
Bye<br />
$ <br />
<br />
and congratulate yourself. You are now ready for the next and hopefully easy part, installing WeBWorK.<br />
<br />
== Downloading the WeBWorK System Software and Problem Libraries ==<br />
We are finally at the point where we can start downloading and installing WeBWorK. We will use CVS to download WeBWorK. This is easy and it will also make it easy to update the system in the future. Note that the following are rather long commands; it is much easier to copy (<code>^C</code>) them from this document and paste (<code>&lt;Shift&gt; &lt;Ctrl&gt; &lt;V&gt;</code>) them in a terminal window<br />
<br />
$ cd<br />
$ cd downloads<br />
<br />
$ cvs -d :pserver:anoncvs@cvs.webwork.rochester.edu:/webwork/cvs/system checkout -r rel-2-4-patches webwork2 pg<br />
$ cvs -d :pserver:anoncvs@cvs.webwork.rochester.edu:/webwork/cvs/asu checkout database_problems<br />
<br />
The first download gives you the latest released version with patches.<br />
The second download contains the WeBWorK National Problem Library. This now includes the Rochester and Union Libraries along with others as sub libraries. There is quite a bit of overlap between these libraries but now you system is loaded with many thousands of WeBWorK problems (over 14,000 in the National Problem Library main collection alone).<br />
<br />
== Installing WeBWorK ==<br />
=== Move the System into the Required Directories ===<br />
As <code>root</code> create a <code>webwork</code> directory under <code>/opt</code> and move directories there. <br />
<br />
$ su<br />
<root password><br />
# mkdir /opt/webwork<br />
# mv webwork2 /opt/webwork/<br />
# mv pg /opt/webwork/<br />
<br />
Now create the <code>courses</code> and <code>libraries</code> directories under <code>webwork</code> and copy and move content there.<br />
<br />
# mkdir /opt/webwork/courses<br />
# mkdir /opt/webwork/libraries<br />
# mv database_problems/ /opt/webwork/libraries/<br />
# cd /opt/webwork/webwork2/courses.dist<br />
# cp *.lst /opt/webwork/courses/<br />
# cp -r modelCourse/ /opt/webwork/courses/<br />
<br />
=== Setting Permissions ===<br />
<br />
The PG installation directory and files should be owned by root and not writable by other users:<br />
<br />
# cd /opt/webwork/pg<br />
# chown -R root:root .<br />
# chmod -R u+rwX,go+rX .<br />
<br />
Most WeBWorK directories and files should also be owned by root and not writable by other users:<br />
<br />
# cd /opt/webwork/webwork2<br />
# chown -R root:root .<br />
# chmod -R u+rwX,go+rX .<br />
<br />
Certain data directories need to be writable by the web server. These are <code>DATA</code>, <code>courses</code>, <code>htdocs/tmp</code>, <code>logs</code>, and <code>tmp</code>. It is convenient to give WeBWorK administrators access to these directories as well, so they can perform administrative tasks such as removing temporary files, creating and editing courses from the command line, managing logs, and so on. We will create a new group called <code>wwdata</code>, containing both the WeBWorK administrators and the web server.<br />
<br />
# Select <code>System</code>, <code>Administration</code> and then <code>Users and Groups</code><br />
# Click on <code>Unlock</code><br />
# Enter <code>&lt;your password&gt;</code> and click <code>Authenticate</code><br />
# Select <code>Manage Groups</code><br />
# Click <code>Add Group</code> <br />
# For <code>Group name</code> enter <code>wwdata</code><br />
# Under <code>Group Members</code> select yourself and click <code>OK</code><br />
# Click <code>Close</code><br />
<br />
If there are other users who will also be administering WeBWorK files,<br />
now is a good time to add them. And remember to add them to the <code>wwdata</code> group as above.<br />
<br />
Because system users are not shown by default, we can not simply use the <code>Group Manager</code> to add the Apache2 webserver (which runs as <code>www-data</code>) to the <code>wwdata</code><br />
group so we will do this by hand.<br />
<br />
# cd /etc<br />
# cp group group.bak1<br />
# gedit group<br />
<br />
<br />
# In the gedit window scroll to the last line. <br />
# It should look like <code>wwdata:x:1001:<your userid></code><br />
# Append to this line <code>,www-data</code><br />
# Then Save and Quit<br />
<br />
<br />
<br />
You can check that this succeeded in a terminal window by entering<br />
<br />
# exit<br />
$ id <your userid><br />
<br />
and then you should see <code>wwdata</code> listed under groups. Also<br />
<br />
$ id www-data<br />
<br />
should show wwdata listed under groups. Now we make the WeBWorK directories that need to be writable by the web server have <code>wwdata</code> as their group. The following are rather long commands; you might want to copy them and paste them into your terminal window rather than typing them.<br />
<br />
$ su<br />
<root password><br />
# cd /opt/webwork/webwork2/<br />
# chgrp -R wwdata DATA ../courses htdocs/tmp logs tmp<br />
# chmod -R g+w DATA ../courses htdocs/tmp logs tmp<br />
# find DATA/ ../courses/ htdocs/tmp logs/ tmp/ -type d -a ! -name CVS -exec chmod g+s {} \;<br />
# exit<br />
$<br />
<br />
== Configuring the Shell ==<br />
<br />
To make working with WeBWorK easier, there are a couple of changes you can make to your shell environment.<br />
<br />
Add the WeBWorK <code>bin</code> directory to your path. This will allow you to run WeBWorK command-line utilities without typing the full path to the utility. Goto your home directory and backup your <code>.bashrc</code> file<br />
<br />
$ cd<br />
$ cp .bashrc .bashrc.bak1<br />
<br />
Now edit <code>.bashrc</code><br />
<br />
$ gedit .bashrc<br />
<br />
After the last line add the two lines:<br />
<br />
export PATH=$PATH:/opt/webwork/webwork2/bin<br />
export WEBWORK_ROOT=/opt/webwork/webwork2<br />
<br />
Then save the file and Quit.<br />
<br />
Close your Terminal Window and open a new one so the above changes<br />
take effect. You can check that they have by<br />
<br />
$ echo $PATH<br />
$ echo $WEBWORK_ROOT<br />
<br />
== Checking Module Dependancies ==<br />
<br />
<br />
<br />
WeBWorK includes a script called <code>check_modules.pl</code> that verifies that the needed programs and Perl modules are installed on your system. Run this script to make sure you have installed the required programs and Perl modules.<br />
<br />
$ check_modules.pl apache2<br />
<br />
Scroll up and look through the listing. It should find everything except <code>PHP::Serialization</code>, <code>SOAP::Lite</code>, <code>MIME::Parser</code> and <code>XMLRPC::Lite</code> which are only required if you plan to use WeBWorK with Moodle and <code>tth</code> which is a deprecated display mode. If something is missing (flagged by <code>**</code>), look back through these instructions and/or look at to find where it should have been installed and install it. Note you may have to search in [[Installation Manual for 2.4]] to find out what package it is contained in.<br />
<br />
== Configuring WeBWorK ==<br />
<br />
=== Making Copies of the Distribution Configuration Files ===<br />
<br />
Before configuring the system, you must make local copies of the <code>global.conf</code> and <code>database.conf</code> configuration files, located in <code>/opt/webwork/webwork2/conf/</code> . Since these are owned by <code>root</code><br />
<br />
$ su<br />
<root password><br />
# cd /opt/webwork/webwork2/conf<br />
# cp global.conf.dist global.conf<br />
# cp database.conf.dist database.conf<br />
<br />
=== Global Configuration ===<br />
<br />
Most WeBWorK configuration is done in the file <code>/opt/webwork2/conf/global.conf</code>. This file provides system-wide configuration settings, and defaults for course settings. Any setting in this file can be overridden in the <code>course.conf</code> file for a particular course. To override a setting for a course, just put the new setting (using the same syntax as is in <code>global.conf</code>) in the <code>course.conf</code> file.<br />
<br />
There are several options that must be set for WeBWorK to work with your system. The rest of the file consists of customization options. Now edit <code>global.conf</code><br />
<br />
# cd /opt/webwork/webwork2/conf<br />
# gedit global.conf<br />
<br />
WeBWorK uses the DateTime module. DateTime is supposed to be able to determine the local timezone itself without you having to enter it but this often fails so it is best to just set it here. For is a list of timezones recognized by DateTime go to<br />
http://search.cpan.org/dist/DateTime-TimeZone/ . These timezones are more refined than standard timezone usage in that they include switches to daylight savings time (e.g. some parts of a time zone may make the switch and others may not). For example if your server is in the eastern US, on the list you will see <code>DateTime::TimeZone::America::New_York</code> and you should replace <code>$siteDefaults{timezone} = "";</code> by <code>$siteDefaults{timezone} = "America/New_York";</code> <br />
<br />
# Search for <code>$siteDefaults{timezone} = "";</code> and enter your local timezone.<br />
<br />
At this point <code>TtH</code> is a deprecated display mode which we didn't install so we have to remove it from the listof possible display modes. <br />
<br />
# Search for <code>formattedText</code> and comment out the line <code>"formattedText", # format math expressions using TtH</code><br />
so it becomes<br />
<br />
# "formattedText", # format math expressions using TtH<br />
<br />
We need to set a password that WeBWorK uses when it communicates with the MySQL database. Note that this is not the same as the <code>&lt;mysql root password&gt;</code> which is the password the MySQL root user uses.<br />
# Search for <code>$database_password = "";</code> and replace this by <br /> <code>$database_password = "database_password";</code> <br />
where of course you should replace 'database_password' with your own password. Remember this password as we will need it below.<br />
<br />
WeBWorK sends mail in three instances. The PG system sends mail to report answers to questionnaires and free-response problems. The mail merge module is used to send mail to course participants, i.e. to report scores. The feedback module allows participants to send mail to course instructors.<br />
<br />
To send mail, WeBWorK needs the address of an SMTP server. Normally you will use the address of your school's SMTP server. If the local machine is running an SMTP server, use <code>localhost</code>. IMPORTANT: Our instructions above did not install an SMTP server so you will have to install and configue one if you do not use your school's SMTP server. When connecting to the SMTP server, WeBWorK must also send an email address representing the sender of the email (this has nothing to do with the <code>From</code> address on the mail message). Edit the lines<br />
$mail{smtpServer} = 'mail.yourschool.edu'; <br />
$mail{smtpSender} = 'webwork@yourserver.yourschool.edu';<br />
<br />
entering the appropriate information.<br />
<br />
If you want WeBWorK questionnaires or similar things from different courses to be mailed to a central person or persons (e.g. the WeBWorK administrator), edit the lines<br />
<br />
$mail{allowedRecipients} = [<br />
#'prof1@yourserver.yourdomain.edu',<br />
#'prof2@yourserver.yourdomain.edu',<br />
];<br />
<br />
appropriately removing the <code>#</code> and using the professor(s) actual email address(es). In order to have professors from individual courses receive such email, this <br />
should be set in course.conf to the addresses of professors of each course.<br />
<br />
Then save the file and Quit.<br />
<br />
<br />
Now become a regular user again<br />
<br />
# exit<br />
$<br />
<br />
WeBWorK uses a single database, called <code>webwork</code>, for all courses. We will create the <code>webwork</code> database now.<br />
<br />
To do this do the following (before you just copy, paste and hit <code>&lt;Enter&gt;</code> notice that you have to replace <code>database_password</code> with the password you set when editing <code>global.conf</code> above):<br />
<br />
$ mysql -u root -p mysql<br />
Enter password: <mysql root password><br />
mysql> CREATE DATABASE webwork;<br />
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, LOCK TABLES ON webwork.* TO webworkWrite@localhost IDENTIFIED BY 'database_password';<br />
mysql> exit<br />
Bye<br />
$ <br />
<br />
where as we said replace <code>database_password</code> with the password you set when editing <code>global.conf</code> above.<br />
<br />
Since version 2.3.0 WeBWorK has an automatic database upgrade system. Rather than manually issuing SQL commands to make changes to the database, or using ad-hoc scripts like wwdb_addgw, there is a single script called <code>wwdb_upgrade</code> that applies any necessary updates. It should be run when creating a new database, and any time you upgrade WeBWorK.<br />
<br />
$ /opt/webwork/webwork2/bin/wwdb_upgrade -v<br />
<br />
=== jsMath Settings ===<br />
<br />
Version 2.0 of jsMath introduced a new fallback method for when the TeX fonts are not available on the student's computer. This uses images of the individual TeX characters in place of the TeX fonts. These are distributed in <code>webwork2/htdocs/jsMath/jsMath-fonts.tar.gz</code>, and you need to unpack this tarball before jsMath will work properly. Use the command<br />
<br />
$ su<br />
<root password><br />
# cd /opt/webwork/webwork2/htdocs/jsMath<br />
# tar vfxz jsMath-fonts.tar.gz<br />
<br />
This will unpack the archive. Since there are 20,000 tiny files, it can take a little while, so the <code>v</code> option is used to show you the names as they are unpacked so that you know the command is actually doing something. Once the images are unpacked, jsMath's image mode fallback (the default fallback method) will work properly.<br />
<br />
<br />
== Configuring Apache ==<br />
WeBWorK ships with an Apache config file that needs to linked into your Apache configuration process. The file is named <code>webwork.apache2-config.dist</code> and located in the <code>conf</code> directory. First, copy the file to <code>webwork.apache2-config</code>:<br />
<br />
# cd /opt/webwork/webwork2/conf<br />
# cp webwork.apache2-config.dist webwork.apache2-config<br />
<br />
and now link it into your Apache configuration process<br />
<br />
# cd /etc/apache2/conf.d<br />
# ln -s /opt/webwork/webwork2/conf/webwork.apache2-config webwork.conf<br />
<br />
Then restart Apache <br />
<br />
# apache2ctl graceful<br />
# exit<br />
$<br />
<br />
== Test your configuration ==<br />
<br />
# Test the <code>/webwork2</code> location by visiting <code>http://yourserver.yourschool.edu/webwork2</code>. You should see the WeBWorK home page with no courses listed. Actually the directory <code>/opt/webwork/courses/</code> does contain the <code>modelCourse</code> but the <code>modelCourse</code> is not a real course so you will get an error message if you try to log into it. It will be used a as model for setting up other courses. For this reason <code>/opt/webwork/courses/modelCourse/</code> contains a file named <code>hide_directory</code> and so the <code>modelCourse</code> is not visible.<br />
# Test the <code>/webwork2_files</code> location by visiting <code>http://yourserver.yourschool.edu/webwork2_files</code>. You should see the "WeBWorK Placeholder Page".<br />
# You cannot test the <code>/webwork2_course_files</code> location until you have created a course.<br />
<br />
==If Something is Wrong ==<br />
If something is wrong one of the first things to check is that the config files have been edited correctly (e.g. one time a wrapped line in <code>global.conf</code> caused me problems, another time it was a missing single quote). A quick way to check this is to do a <code>diff</code> between the edited and distributed versions and check that <code>diff</code> reports the changes you made and only those.<br />
<br />
# exit<br />
$<br />
$ cd /etc/apache2/<br />
$ diff apache2.conf apache2.conf.bak1<br />
$ cd /opt/webwork/webwork2/conf/<br />
$ diff global.conf global.conf.dist<br />
$ diff database.conf database.conf.dist<br />
$ diff webwork.apache2-config webwork.apache2-config.dist <br />
<br />
If something is wrong and you fix it, you will have to restart Apache for the changes to take effect<br />
<br />
$ su<br />
<root password><br />
# apache2ctl graceful<br />
# exit<br />
$<br />
<br />
== Create the admin Course ==<br />
<br />
[[Course Administration]] gives information about creating courses. Here we will give explicit instructions for doing this.<br />
<br />
$ su<br />
<root password><br />
# newgrp wwdata<br />
# umask 2<br />
# cd /opt/webwork/courses<br />
# /opt/webwork/webwork2/bin/addcourse admin --db-layout=sql_single --users=adminClasslist.lst --professors=admin<br />
# exit<br />
# exit<br />
$<br />
<br />
Now goto <code>http://yourserver.yourschool.edu/webwork2</code> and should see the WeBWorK home page with <code>Course Adninistration</code> listed at the top. Click on it and login with Username <code>admin</code> and Password <code>admin</code> . This first thing you should do is to click on <code>Password/Email</code> and change <code>admin</code> 's password to something more secure than <code>admin</code> . <br />
<br />
Unless you choose oherwise, users with <code>professor</code> privilges in the <code>admin</code> course (i.e. WeBWorK administrators) will automatically be added to new courses with <code>professor</code> privilges and the same password as in the <code>admin</code> course. Initially the only such user is <code>admin</code> (hopefully you are not confused by the fact that the course <code>admin</code> has a user named <code>admin</code>). It's usually convenient make yourself a WeBWorK administrator. To do this (assuming you are logged in as <code>admin</code> to the <code>admin</code> course at <code>http://yourserver.yourschool.edu/webwork2/admin</code> )<br />
# Click on <code>Classlist Editor</code> in the left panel<br />
# Check <code>Add 1 student(s)</code> and click <code>Take Action!</code><br />
# Enter the appropiate information (you can leave the last three items blank) and click <code>Add Students</code><br />
# Click on <code>Classlist Editor</code> in the left panel again<br />
<br />
# When you enter a new student, by default their <code>Student ID</code> is used as their password. We'll change this now.<br />
# Select yourself with a check mark and then check <code>Give new password to Selected users</code> or just check <code>Give new password to All users</code> (as a safely mechanism you can not change the password for the user you are logged in as, currently <code>admin</code>, this way) and then click <code>Take Action!</code><br />
# Enter the password, check <code>Save changes</code> and then click <code>Take Action!</code><br />
# Finally give yourself <code>professor</code> privilges by selecting yourself with a check mark, checking <code>Edit Selected users</code> and then clicking <code>Take Action!</code> (or by just clicking on the "pencil" next to your login name which is a much faster way to edit classlist data for a single user)<br />
# Now at the far right change <code>Permission Level</code> from <code>student</code> to <code>professor</code><br />
# Check <code>Save changes</code> and then click <code>Take Action!</code><br />
<br />
At some point you will probably want to hide the <code>admin</code> course so that it is not listed on the WeBWorK home page. As we noted above the <code>modelCourse</code>, which is already hidden, is not a real course so you will get an error message if you try to log into it. This is a good reason to hide it. The <code>modelCourse</code> is very useful as a model (hence its name) for setting up other courses. The <code>admin</code> course is used for administering WeBWorK and even though regular users can not log into it (you did change the <code>admin</code> password, didn't you!!), it a little bit cleaner and safer to hide it from prying eyes. <br />
To hide a course place a file named <code>hide_directory</code> in the course directory and it will not show up in the courses list on the WeBWorK home page. It will still appear in the Course Administration listing. If you do this you will still be able to access the <code>admin</code> course using the URL <code>http://yourserver.yourschool.edu/webwork2/admin</code> but you will not see a link for it on the WeBWorK home page <code>http://yourserver.yourschool.edu/webwork2</code> . Let's hide the <code>admin</code> course.<br />
<br />
$ sudo cp /opt/webwork/courses/modelCourse/hide_directory /opt/webwork/courses/admin<br />
password:<your password><br />
<br />
<br />
Now goto <code>http://yourserver.yourschool.edu/webwork2</code> and no course will be listed.<br />
<br />
== Starting and Stopping Apache, MySQL and the GNOME desktop GUI ==<br />
If you make changes to the system, you will have to restart <code>apache2</code> before the changes take effect. On rare occasions you may need to restart <code>MySQL</code>. <br />
=== Starting and Stopping Apache ===<br />
You have to run these commands as <code>root</code>.<br />
<br />
To start or restart (i.e. stop and then start) the <code>apache2</code> webserver run the command <br />
<br />
$ sudo apache2ctl graceful<br />
password:<your password><br />
<br />
To stop the Apache webserver run the command <br />
<br />
$ sudo apache2ctl stop<br />
password:<your password><br />
<br />
You can also start or stop apache2, listed as <code>Web server (apache2)</code>, by using the GUI interface.<br />
# Select <code>System</code>, <code>Administration</code> and then <code>Services</code><br />
# Scroll down to <code>Web server (apache2)</code><br />
# If <code>apache2</code> is running, uncheck its check box and click <code>Close</code> to stop it<br />
# If <code>apache2</code> is stopped, check its check box and click <code>Close</code> to start it<br />
<br />
Another method is to use the <code>init.d</code> script <code>apache2</code>. Run<br />
$ sudo /etc/init.d/apache2<br />
password:<your password><br />
and you will get a list of allowed commands (<code>start</code>, <code>stop</code>, <code>restart</code>, etc).<br />
<br />
Note that in an earlier version of Ubuntu I found using the GUI interface somewhat unreliable.<br />
<br />
=== Starting and Stopping MySQL ===<br />
You have to run these commands as <code>root</code>.<br />
<br />
To start the <code>MySQL</code> server run the command <br />
<br />
$ sudo /etc/init.d/mysql start<br />
password:<your password><br />
<br />
To stop the <code>MySQL</code> server run the command <br />
<br />
$ sudo /etc/init.d/mysql stop<br />
password: <your password><br />
<br />
To restart the <code>MySQL</code> server run the command <br />
<br />
$ sudo /etc/init.d/mysql restart<br />
password: <your password><br />
<br />
You can also start or stop MySQL, listed as <code>Database server (mysql)</code>, by using the GUI interface.<br />
<br />
# Select <code>Desktop</code>, <code>Administration</code> and then <code>Services</code><br />
# Scroll down to <code>Database server (mysql)</code><br />
# If <code>mysql</code> is running, uncheck its check box and click <code>Close</code> to stop it<br />
# If <code>mysql</code> is stopped, check its check box and click <code>Close</code> to start it<br />
<br />
=== Starting and stopping the GNOME desktop GUI ===<br />
<br />
The GNOME desktop is automatically started when the system boots. <br />
<br />
To stop <code>GNOME</code> so that you only have a standard terminal window run the following in a standard terminal window<br />
<br />
$ sudo /etc/init.d/gdm stop <br />
password: <your password><br />
<br />
If you stopped <code>GNOME</code> and want to restart it run the following in a standard terminal window<br />
<br />
$ sudo /etc/init.d/gdm start <br />
password: <your password><br />
<br />
==Install the WeBWorK Problem Libraries ==<br />
Before we create a real course we will install the WeBWorK Problem Libraries.<br />
<br />
===Install the National Problem Library ===<br />
The <code>National Problem Library</code> consists of both WeBWorK problems and methods for searching and selecting problems. Also it contains as sub libraries many of the other standard libraries. Normally this library is referred to as the <code>ProblemLibrary</code> but the downloaded CVS directory for it is named <code>database_problems</code>. So the first thing we do is to link <code>ProblemLibrary</code> to <code>database_problems</code>. <br />
<br />
$ cd /opt/webwork/libraries/<br />
$ sudo ln -s database_problems ProblemLibrary<br />
password: <your password><br />
<br />
Next we have to edit <code>global.conf</code>.<br />
<br />
$ cd /opt/webwork/webwork2/conf<br />
$ su<br />
Password: <root password><br />
# gedit global.conf<br />
<br />
# Search for <code>problemLibrary</code> and replace <code>$problemLibrary{root} = "";</code> by <br /> <code>$problemLibrary{root} = "/opt/webwork/libraries/ProblemLibrary";</code> <br />
<br />
Then save the file and quit. And return to a regular user<br />
<br />
#exit<br />
$<br />
<br />
We now create a database, called <code>ProblemLibrary</code>, for for the Problem Library.<br />
To do this do the following:<br />
<br />
$ mysql -u root -p mysql<br />
Enter password: &lt;mysql root password&gt;<br />
mysql> CREATE DATABASE ProblemLibrary;<br />
mysql> GRANT SELECT ON ProblemLibrary.* TO webworkWrite@localhost;<br />
mysql> exit<br />
Bye<br />
$ <br />
<br />
Run the installation script making sure you are in the <code>/opt/webwork/libraries/ProblemLibrary</code> directory. This directory<br />
contains the files <code>loadDB2</code> and <code>create_tables2.sql</code>.<br />
<br />
$ cd /opt/webwork/libraries/ProblemLibrary<br />
$ NPL-update<br />
<br />
This has to convert a lot of data (around 14600 files) so please be patient; it can take a long time.<br />
<br />
If at some time in the future you want to upgrade the Problem Library, the process<br />
is simpler. Optionally remove the previous copy of the<br />
library, unpack the new copy in the same place, and run NPL-update.<br />
<br />
===Set up the Rochester and Union Libraries ===<br />
<br />
First we need to edit <code>global.conf</code> one last time<br />
<br />
$ cd /opt/webwork/webwork2/conf<br />
$ su<br />
Password: <root password><br />
# gedit global.conf<br />
<br />
# Search for <code>courseFiles{problibs}</code> and scroll down several lines to the line <br /> <code># rochesterLibrary =&gt; "Rochester",</code><br />
# Uncomment this line (i.e. remove the <code>#</code>) so it becomes <br /> <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code>rochesterLibrary =&gt; "Rochester",</code><br />
# Directly below this line add the line <br /> <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code>unionLibrary =&gt; "Union",</code><br />
# Search for <code>macrosPath</code> and scroll down several lines to the line <br /> <code>$pg{directories}{macros},</code><br />
# After this line add the line: <br /> <code>'/opt/webwork/libraries/database_problems/macros/Union',</code> <br />
<br />
Don't forget the coma (<code>,</code>) at the end of these lines. Then save the file and quit.<br />
<br />
Since we have edited <code>global.conf</code> a lot and this is a very critical file, it would be a good idea to run<br />
<br />
<br />
# exit<br />
$ diff global.conf global.conf.dist<br />
<br />
and check that you haven't made any mistakes (e.g. by introducing an inadvertant line break, etc).<br />
<br />
We next put links to the Rochester and Union Libraries in the <code>modelCourse</code> so that when we create courses copying templates from the <code>modelCourse</code>, these libraries will be available. Skip this step if you usually only want to use National Problem Library.<br />
<br />
$ cd /opt/webwork/courses/modelCourse/templates/<br />
$ sudo ln -s /opt/webwork/libraries/database_problems/Union unionLibrary<br />
password: <your password><br />
$ sudo ln -s /opt/webwork/libraries/database_problems/Rochester rochesterLibrary<br />
<br />
If you want to put another library into the <code>modelCourse</code>, just do the analogous thing. If you just want the additional library in a particular course, add the link in the <code>templates</code> directory of that course. If you look in the directory <code>/opt/webwork/libraries/database_problems/</code> you might find other libraries that are not yet listed in <code>global.conf</code> (like <code>Union</code> above) and these can be added in the same way we added <code>Union</code>. Usually they do not require additional macros like <code>Union</code> did. Finally if you add a library with non standard symbols in the name (e.g. <code>uva-statLibrary</code>) you have to use single quotes when adding it to <code>global.conf</code>, e.g. <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code>'uva-statLibrary' => "UVA-Stat",</code> <br><br />
It's easier to just avoid such names.<br />
<br />
==Create Your First Actual Course ==<br />
<br />
Now log into the <code>admin</code> course ( <code>http://yourserver.yourschool.edu/webwork2/admin</code> ) as yourself or <code>admin</code> and <br />
# click on <code>Add Course</code><br />
# For <code>Course ID</code> enter <code>myTestCourse</code><br />
# For <code>Course Title</code> enter <code>My Test Course</code><br />
# Enter your institution<br />
# Leave <code>Add WeBWorK administrators to new course</code> checked<br />
# Add an additional instructor if you wish<br />
# Copy templates from: <code>modelCourse</code> (the default action)<br />
# Select sql_single for the database layout.<br />
# Click on <code>Add Course</code><br />
# Click <code>Log into myTestCourse</code><br />
<br />
and log in either as <code>admin</code> or yourself.<br />
<br />
At some point you will probably want to "hide" <code>myTestCourse</code> from general view but you already know how to do that.<br />
<br />
==Test that Things are Working Properly ==<br />
<br />
We will test out a few important parts of WeBWorK. If you run into problems, you should look at the Apache error log which is located at <code>/var/log/apache2/error.log</code>.<br />
<br />
Click on <code>Hmwk Sets Editor</code> on the <code>Main Menu</code>. Then select (by clicking the circle button) <code>Import</code>, select <code>setDemo.def</code> from the <code>from</code> drop down list and select <code>all current users</code> from the <code>assigning this set to</code> drop down list. Then hit <code>Take Action!</code><br />
<br />
Now click on <code>Homework Sets</code> on the <code>Main Menu</code> and click on <code>Demo</code>. Then look at the problems. Mathematical equations should be typeset. If not, edit the file <code>Constants.pm</code> in the directory <code>/opt/webwork/webwork2/lib/WeBWorK</code>. Change the line <code>$WeBWorK::PG::ImageGenerator::PreserveTempFiles = 0;</code> to <code>...::PreserveTempFiles = 1;</code>. Then restart Apache and view the first couple problems or some new ones. Then look in the directory <code>/opt/webwork/webwork2/tmp/</code>. <code>cd</code> to one of the <code>ImageGenerator.../tmp/</code> directories and look at the error and log files there. When you fix the problem remember to edit <code>...::PreserveTempFiles = 1;</code> back to 0 and restart Apache or you will be saving a lot of unnecessary files. Another useful trick is to try downloading a hard copy of an assignment and then (assuming there are errors) looking at the various log files that are linked to on the output page.<br />
<br />
When you continue looking at problems you will get an error when you try to look at Problem 6 because we have not configured the CAPA macros which are required to display CAPA problems. Unless you are teaching physics you probably don't need them. Also in Problem 9 the Java applet will not load. Problem 9 was written in the 90's and used an applet on a server at The Johns Hopkins University. The server went away a long time ago but have retained this problem for historical reasons and also because it is a example of several things (e.g. WeBWorK problems can include applets running on remote servers but this can lead to other problems). <br />
<br />
Next click on <code>Prob. List</code> to bring back the Problem List Page and click on <code>Download a hardcopy of this homework set</code>. The page is a little complicated because you are a professor but you can just scroll to the bottom and click on <code>Generate hardcopy for selected users and selected sets</code>. You will get an error (because of the bad Problem 6) but just click <code>Download Hardcopy</code> to get what was generated. Also you can see links to various <br />
informational files that are available if you run into problems (normally these files are removed if there are no errors).<br />
<br />
Another thing to do is to use <code>Email</code> on the <code>Main Menu</code>. Again this page is a little complicated because you can do a lot of things with it (including mail merge) but at this point just select yourself in the list to the right and hit <code>Send Email</code> at the bottom. You should receive two emails. One is the message you just sent and the other is an email with subject "WeBWorK email sent" giving information on your mailing. <br />
<br />
As a final test click on <code>Library Browser</code> on the <code>Main Menu</code>. Click <code>Problem Library </code><br />
and select a <code>Subject</code>, <code>Chapter</code> and <code>Section</code> and then hit <code>View Problems</code>. The first 20 of your selected problems will be displayed. You can also test that you can access any additional Problem Libraries that you installed.<br />
<br />
If all the above tests work, you can be pretty confident that WeBWorK is working properly.<br />
<br />
Go back to <code>Hmwk Sets Editor</code> on the <code>Main Menu</code>. Then select (by clicking the circle button) <code>Import</code>, select <code>setOrientation.def</code> from the <code>from</code> drop down list and select <code>all current users</code> from the <code>assigning this set to</code> drop down list. Then hit <code>Take Action!</code>. Then go through the Orientation problems. This is a good first set to use for introducing students to WeBWorK.<br />
<br />
If you are new to WeBWorK, you should probably add a regular student to myTestCourse and log in as that student to see what the student interface looks like. It's much simpler than the professor interface.<br />
Click on <code>Classlist Editor</code> on the <code>Main Menu</code>.<br />
Then select (by clicking the circle button) <code>Add 1 student(s)</code>and hit <code>Take Action!</code>. Add one student, say Jane Smith, with <code>Student ID</code> <code>1234</code> and <code>Login Name</code> <code>jsmith</code>.<br />
Jane Smith's initial password will be her <code>Student ID</code> <code>1234</code>. Now login as Jane Smith and play around a little.<br />
<br />
==Optional Configurations==<br />
'''Optional A''' stores WeBWorK's "temporary" files in a separate partition. <br />
'''Optional B''' installs and configures a lightweight webserver to serve static files.<br />
'''Optional C''' configures Apache so that access to WeBWorK will be through SSL.<br />
<br />
===Implement Optional A (wwtmp)===<br />
<br />
Now is the time to implement '''Optional A''' if you choose to do so. Actually you can do this at any time and your active courses will continue to function seemingly without change. The only change behind the scenes will be that temporary files will be stored in a different location.<br />
<br />
First we set the group and permissions for the <code>wwtmp</code> directory<br />
<br />
$ su<br />
<root password><br />
# cd /var/www<br />
# chgrp wwdata wwtmp<br />
# chmod ug+w wwtmp<br />
# chmod g+s wwtmp<br />
<br />
Next we have to edit <code>global.conf</code> so that WeBWorK uses the new <code>wwtmp</code> directory. Since we have a working WeBWorK system, first we make a backup copy of <code>global.conf</code>.<br />
<br />
<br />
# cd /opt/webwork/webwork2/conf<br />
# cp global.conf global.conf.bak1<br />
# gedit global.conf<br />
<br />
Now edit <code>global.conf</code>. Find the lines <br />
<br />
$webworkDirs{htdocs_temp} = "$webworkDirs{htdocs}/tmp";<br />
$webworkURLs{htdocs_temp} = "$webworkURLs{htdocs}/tmp";<br />
and replace them by <br />
#$webworkDirs{htdocs_temp} = "$webworkDirs{htdocs}/tmp";<br />
#$webworkURLs{htdocs_temp} = "$webworkURLs{htdocs}/tmp";<br />
$webworkDirs{htdocs_temp} = '/var/www/wwtmp';<br />
$webworkURLs{htdocs_temp} = '/wwtmp';<br />
<br />
Next find the lines <br />
<br />
$courseDirs{html_temp} = "$courseDirs{html}/tmp";<br />
$courseURLs{html_temp} = "$courseURLs{html}/tmp";<br />
and replace them by <br />
#$courseDirs{html_temp} = "$courseDirs{html}/tmp";<br />
#$courseURLs{html_temp} = "$courseURLs{html}/tmp";<br />
$courseDirs{html_temp} = "/var/www/wwtmp/$courseName";<br />
$courseURLs{html_temp} = "/wwtmp/$courseName";<br />
<br />
Then save the file and quit. If you look at the <code>wwtmp</code> directory you will find it empty but after you restart apache and then access some WeBWorK problems, you will find temporary directories and files in <code>wwtmp</code>. Remember your have to restart apache for these changes to take effect.<br />
<br />
===Implement Optional B (lighttp)===<br />
<br />
As is the case for '''Optional A''' you can implement '''Optional B''' at any time and your active courses will continue to function seemingly without change. The only change behind the scenes will be that static images and pages will be served by a light weight web server.<br />
<br />
First we install the light weight webserver <code>lighttp</code><br />
<br />
# Open the <code>Synaptic Package Manager</code> (select <code>System</code>, <code>Administration</code>, <code>Synaptic Package Manager</code>). <br />
# Select <code>Search</code> <br />
# Search for <code>lighttp</code> and select it<br />
# In the pop up window <code>Mark additional required changes?</code> click <code>Mark</code> to accept the requirements.<br />
# Now click <code>Apply</code> and <code>Apply</code> again to confirm the changes.<br />
<br />
You can now quit the <code>Synaptic Package Manager</code>.<br />
<br />
Now we configure <code>lighttp</code>. First let's make a backup of the configuration file.<br />
<br />
<br />
$ su<br />
<root password><br />
# cd /etc/lighttpd<br />
# cp lighttpd.conf lighttpd.conf.bak1<br />
<br />
Now edit <code>lighttpd.conf</code>. <br />
<br />
# gedit lighttpd.conf<br />
<br />
Uncomment the line<br />
# "mod_status",<br />
so it becomes<br />
"mod_status",<br />
<br />
Search for the line<br />
server.document-root = "/var/www/"<br />
and under this line add the line<br />
alias.url = ("/webwork2_files/" => "/opt/webwork/webwork2/htdocs/")<br />
<br />
Apache2 is listening on port 80 so we set lighttp to listen on port 81. Find the line<br />
# server.port = 81<br />
and uncomment it <br />
server.port = 81<br />
<br />
Finally uncomment the line<br />
# status.status-url = "/server-status"<br />
so it becomes<br />
status.status-url = "/server-status"<br />
Then save the file and quit.<br />
<br />
Now restart lighttp<br />
<br />
$su<br />
<root password><br />
# /etc/init.d/lighttpd restart<br />
# exit<br />
$<br />
<br />
Note that you can just run <code>/etc/init.d/lighttpd</code> to get a list of all options.<br />
<br />
Now test your server by connecting to<br />
"http://localhost:81/" and/or connecting to your<br />
server from a browser on a remote machine. You should see the page '''It works!''' indicating that lighttp is running.<br />
<br />
You can check lighttp's status by connecting to<br />
"http://localhost:81/server-status" using a browser on your machine or from to "http://yourserver.yourschool.edu:81/server-status" from a browser on a remote machine.<br />
<br />
The Server-Status page doesn't indicate that lighttp is the web server, but it's certainly different than apache's Server-Status page "http://localhost/server-status".<br />
<br />
Next we configure WeBWorK to take advantage of lighttp.<br />
<br />
First let's make a backup copy of <code>global.conf</code> so that we can easily back out of these changes if necessary.<br />
<br />
# cd /opt/webwork/webwork2/conf<br />
# cp global.conf global.bak2<br />
<br />
<br />
Now edit <code>global.conf</code>. Note that while '''Optional B''' is independent of '''Optional A''', we assume most people implementing '''Optional B''' will have already implemented '''Optional A'''. Therefore we give instructions for editing <br />
global.conf assuming that '''Optional A''' has been implemented. If this is not the case, modify the instructions below accordingly. Also replace <code>yourserver.yourschool.edu</code> with the correct address.<br />
<br />
# gedit global.conf<br />
<br />
Find the line<br />
$webwork_htdocs_url = "/webwork2_files";<br />
and replace it by<br />
#$webwork_htdocs_url = "/webwork2_files";<br />
$webwork_htdocs_url = 'http://yourserver.yourschool.edu:81/webwork2_files';<br />
<br />
Find the line<br />
$webworkURLs{htdocs_temp} = '/wwtmp'<br />
and replace it by<br />
#$webworkURLs{htdocs_temp} = '/wwtmp';<br />
$webworkURLs{htdocs_temp} = 'http://yourserver.yourschool.edu:81/wwtmp';<br />
<br />
Find the line<br />
$courseURLs{html_temp} = "/wwtmp/$courseName";<br />
and replace it by<br />
#$courseURLs{html_temp} = "/wwtmp/$courseName";<br />
$courseURLs{html_temp} = "http://yourserver.yourschool.edu:81/wwtmp/$courseName";<br />
<br />
Then save the file and quit.<br />
<br />
Now restart apache and lighttp.<br />
<br />
$ sudo apache2ctl graceful<br />
password:<your password><br />
$ sudo /etc/init.d/lighttpd restart<br />
<br />
To test things go to your test course <code>http://yourserver.yourschool.edu/webwork2/myTestCourse/</code>. Before you login right click on the WeBWorK icon in the upper left hand corner of the login page. The click on Properties (or whatever is appropriate on your browser) and check that the image is being served from port 81 (something like <code>http://yourserver.yourschool.edu:81/webwork2_files/images/webwork_rectangle.png</code>. Then log into your course and view a problem with typeset equations (e.g. Problem 1 of the Demo set). Again right click on the typeset equation and check that the image is being served from port 81.<br />
<br />
===Implement Optional C (SSL)===<br />
'''Optional C''' configures apache so that access to WeBWorK will be through an encrypted Secure Sockets Layer (SSL) with an https: URL. Note that if you implemented '''Optional B''', the non encrypted lighttp server will be used for images, etc but there is no harm in that.<br />
<br />
I cribbed these directions from several sources, the main one being http://www.akadia.com/services/ssh_test_certificate.html.<br />
<br />
We will create and work in a <code>tmp</code> directory.<br />
<br />
$ cd<br />
$ mkdir tmp<br />
$ cd tmp<br />
<br />
First we create an RSA Private Key.<br />
<br />
$openssl genrsa -des3 -out server.key 1024<br />
<br />
When you are asked for a <code>pass phrase</code>, enter a phrase which we refer to as <code>&lt;my pass phrase&gt;</code> and then confirm it. Next generate a Certificate Signing Request<br />
openssl req -new -key server.key -out server.csr<br />
<br />
Enter the requested information. '''Important:''' when you are prompted for the <code>Common Name</code> enter your server's fully qualified domain name, something like <code>yourserver.yourschool.edu</code>. You can leave the last two items <br />
A challenge password []:<br />
An optional company name []:<br />
blank.<br />
<br />
One unfortunate side-effect of the pass-phrased private key is that Apache will ask for the pass-phrase each time the web server is started. Obviously this is not necessarily convenient as someone will not always be around to type in the pass-phrase, such as after a reboot or crash. We will remove this but you must keep this file secure.<br />
<br />
$ cp server.key server.key.bak1<br />
$ openssl rsa -in server.key.bak1 -out server.key<br />
<br />
Next we generate a self-signed certificate which is good for 365 days<br />
<br />
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt<br />
<br />
Now we become root, move these files, and set their group and permission.<br />
<br />
$ su<br />
<root password><br />
# mv server.crt /etc/ssl/private<br />
# mv server.key /etc/ssl/private<br />
# cd /etc/ssl/private<br />
# chgrp ssl-cert server.*<br />
# chmod 640 server.*<br />
<br />
Next we enable the <code>mod_ssl</code> module<br />
# a2enmod ssl<br />
<br />
Now we have to configure Apache to use SSL.<br />
# cd /etc/apache2/sites-enabled/<br />
# cp default default.bak1<br />
# gedit default<br />
<br />
Replace the first line<br />
NameVirtualHost *<br />
by the two lines<br />
NameVirtualHost *:80<br />
NameVirtualHost *:443<br />
Now edit the next non blank line<br />
<VirtualHost *><br />
changing it to<br />
<VirtualHost *:80><br />
Next copy the entire section <br />
<VirtualHost *:80> <br />
...<br />
</VirtualHost><br />
(that is the whole VirtualHost section to the end of the file) and paste it into the file at the end of the file. Now we edit this new pasted section.<br />
Edit the new second<br />
<VirtualHost *:80><br />
changing it to<br />
<VirtualHost *:443><br />
Now at the end of the file just above the line<br />
</VirtualHost><br />
add the three lines<br />
SSLEngine on<br />
SSLCertificateFile /etc/ssl/private/server.crt<br />
SSLCertificateKeyFile /etc/ssl/private/server.key<br />
Then save the file and quit.<br />
Finally we restart Apache<br />
# apache2ctl graceful<br />
and test things. Connect to https://yourserver.yourschool.edu/webwork2/mtTestCourse<br />
You will be asked to accept the certificate. After you do so things should work just as before except that all the connection will be via https (except for images, etc if you using lighttp). <br />
<br />
Assuming that everything is working, the last thing we do is set things up so that requests to http://yourserver.yourschool.edu/webwork2/ are automatically redirected to https://yourserver.yourschool.edu/webwork2/.<br />
<br />
# gedit default<br />
<br />
In the <br />
<VirtualHost *:80><br />
section just above the line<br />
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/<br />
add the line<br />
Redirect permanent /webwork2 https://yourserver.yourschool.edu/webwork2<br />
where of course you should edit <code>yourserver.yourschool.edu</code> appropriately.<br />
Then save the file and quit.<br />
Restart Apache<br />
# apache2ctl graceful<br />
and try connecting to http://yourserver.yourschool.edu/webwork2/. The real connection should be through https://yourserver.yourschool.edu/webwork2/.<br />
<br />
==Where to go From Here ==<br />
<br />
You should play around with <code>myTestCourse</code> e.g. click on <code>Library Browser</code> and browse the <code>Problem Library</code> and also the <code>Rochester</code> and <code>Union</code> libraries.<br />
<br />
Look at http://webhost.math.rochester.edu/webworkdocs/docs/courseadmin/usingwebwork<br />
<br />
Read [[Course Administration]] for more information about creating courses.<br />
<br />
Consult [[Category:Administrators]] for other WeBWorK documentation for system administrators.<br />
<br />
-- Main.ArnoldPizer - 15 May 2008 <br /><br />
<br />
[[Category:Installation Manuals]]</div>Aftermath