Item 1

From WeBWorK_wiki
Revision as of 11:42, 3 August 2022 by Apizer (talk | contribs) (Created page with "===Implement Option B (lighttpd)=== As is the case for '''Option A''' you can implement '''Option B''' at any time and your active courses will continue to function seemingly...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Implement Option B (lighttpd)

As is the case for Option A you can implement Option 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, pages and MathJax (if you installed it locally) will be served by a light weight web server.

Install and Configure lighttpd

First we install the light weight webserver lighttpd

Run the command

$ sudo apt install lighttpd
[sudo] password for wwadmin: <wwadmin password>

Now we configure lighttpd. First let's make a backup of the configuration file.

$ cd /etc/lighttpd
$ sudo cp lighttpd.conf lighttpd.conf.bak1
[sudo] password for wwadmin: <wwadmin password>

Now edit lighttpd.conf.

$ sudo nano lighttpd.conf

Apache2 is listening on port 80 so we need an alternate port for lighttp to listen to. Standard alternate ports for this are usually 81, 8000, or 8080. 8080 is the only port that is listed as an official alternate at . Note that in rare cases an institution may block httpd requests to port 8080. If any of your students report that they can not see graphics, they will have to request that access to requests to port 8080 be allowed.

Find the line

server.port        = 80

and replace it by

server.port        = 8080

Now we make a few more changed that allow MathJax to run under lighttpd. You can skip these if you are running MathJax remotely. At the top of the file in the section server.modules = , under the line


add the line


Then below the closing parentheses and above the line

server.document-root        = "/var/www/html"

add the lines

setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
alias.url = ( "/webwork2_files" => "/opt/webwork/webwork2/htdocs/" )

Then save the file and quit.

Now restart lighttp

$ sudo systemctl restart lighttpd

Test lighttpd

First run the command

 $ sudo lsof -i -P -n | grep LISTEN

and check that lighttpd is listening on port 8080

Now test your server by connecting to your server from a browser on a remote machine (""). You should see the Apache2 Ubuntu Default Page but without a graphic for the Ubuntu Logo indicating that lighttp is running . Test the /webwork2_files location by visiting " You should see the "WeBWorK Placeholder Page".

Configure WeBWorK to Take Advantage of Lighttp

First let's make a backup copy of localOverrides.conf so that we can easily back out of these changes if necessary.

$ cd /opt/webwork/webwork2/conf
$ cp localOverrides.conf localOverrides.conf.bak2

Now edit localOverrides.conf. Note that while Option B is independent of Option A, we assume most people implementing Option B will have already implemented Option A. Therefore we give instructions for editing localOverrides.conf assuming that Option A has been implemented. If this is not the case, modify the instructions below accordingly. Also replace with the correct address.

$ nano localOverrides.conf

Find the line

$webworkURLs{htdocs_temp}   = '/wwtmp'

and replace it by

#$webworkURLs{htdocs_temp}   = '/wwtmp';
$webworkURLs{htdocs_temp}   = '';

Find the line

$courseURLs{html_temp}   = "/wwtmp/$courseName";

and replace it by

#$courseURLs{html_temp}   = "/wwtmp/$courseName";
$courseURLs{html_temp}   = "$courseName";

If you installed MathJax locally under the above line add the lines

# Location of MathJax script, used for the MathJax display mode.
$webworkURLs{MathJax}       = '';

If you are running MathJax remotely, don't add the above lines.

Then save the file and quit.

Now restart apache and lighttp.

$ sudo apache2ctl graceful
password:<wwadmin password>
$ sudo systemctl restart lighttpd

Test that Everything is Working Properly

To test things go to your test course Log into your course and view a problem with a graphic image (e.g. Problem 2 of the Demo set. Since you have Admin or Prof privileges, you can view sets which are not yet open). Right click on the image and click on Properties (or whatever is appropriate on your browser, e.g. copy image location) and check that the image is being served from port 8080 (something like

If MathJax is installed locally, to test that MathJax is using lighttpd, view a problem with some typeset equations. Right click on the equation and you should see the MathJax menu which confirms MathJax is being used. Next look at the source code for the page (e.g. right click on most browsers and select "View page source") and in the source, search for tex-chtml.js. You should see that this is being loaded from port 8080. Obviously, if you are running MathJax remotely, you will see it is being loaded from the CDN.

Disabling Option B (lighttpd) for a single course

If your server is hosting courses from different institutions, you may find that you need to disable using lighttpd for a single course, e.g. because the institution blocks access to port 8080. Actually since port 8080 is an "official" alternate httpd port, you should first try to get the network administrators at the institution to grant access to port 8080. Failing this, you can disable using lighttpd and instead use apache for a single course by adding the following lines to the end of the course's course.conf file which is located in the top level directory for the course (usually /opt/webwork/courses/course_name). Note that using apache instead of lighttpd will put a slightly larger load on the server. Also note that you need "admin" level privileges to edit the course.conf file. Instructors with only "professor" level privileges can not do this from within WeBWorK. If you are running MathJax remotely, don't add the last line.

# Do not use lightppd (port 8080) for this course
$webworkURLs{htdocs_temp}   = '/wwtmp';
$courseURLs{html_temp}   = "/wwtmp/$courseName";
$webworkURLs{equationCache} = "$webworkURLs{htdocs_temp}/equations";
$webworkURLs{MathJax}       = "$webworkURLs{htdocs}/mathjax/es5/tex-chtml.js";

I repeat if you are running MathJax remotely, don't add the last line above.