-
Notifications
You must be signed in to change notification settings - Fork 1
Developing WeBWorK on MacOS (using mojolicious)
This document goes through setting up an apache web server with all the needed pieces to run on MacOS. This was last tested on macOS Sonoma (14.3).
Even though macOS comes with apache, I have had more success with a separate installation from homebrew. Before installing apache, start with homebrew, a manager that is able to install a number of open source programs/packages for MacOS. From a terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
perlbrew
is a very handy software package to manage different versions of perl. In addition, it makes working on MACOS and other operating systems nice as upgrades are made. To install perlbrew
curl -L https://install.perlbrew.pl | bash
and if curl
is not installed use brew
to install it with brew install curl
.
Now, you need to install a particular version of perlbrew for example if you are installed 5.36.3, type:
perlbrew install -Duseithreads perl-5.36.3
perlbrew switch perl-5.36.3
and note that if some tests fail, but it still probably will work you may need to force it with
perlbrew --force install -Duseithreads perl-5.36.3
To install perl packages, the command line tool cpanm
is quite nice and I use it instead of cpan and if you have installed perlbrew as above, perlbrew
comes with a handy installer that work across versions of perl:
perlbrew install-cpanm
There is often problems arising from installing the mysql perl package. First, if
cpanm DBD::mysql
fails, then cd to the working directory--it will say where it is. I have found that:
perl Makefile.PL --cflags="-I/usr/local/Cellar/mariadb/10.4.6/include/mysql -I/usr/local/Cellar/mariadb/10.4.6/include -I/usr/local/opt/openssl/include/openssl" --libs="-L/usr/local/opt/openssl/lib -L/usr/local/lib -lmysqlclient"
then make && make install
worked. Note: change the location of the mysql (mariadb) files above to the current version.
First create the directory to store the webwork source and set permissions:
sudo mkdir /opt/webwork
cd /opt/
sudo chown XXX webwork && sudo chgrp _www webwork
where XXX is your username. Type whoami
to determine this.
The webwork code is on github at https://github.com/openwebwork/webwork2
and you should sign up for an account and fork the code by clicking the Fork
button at the top right of the webpage. You should fork this into your own account.
You can clone the code by copying the URL by clicking the Download or Clone button (green button) and use your favorite Git management software. I use either SourceTree or the built-in via the Atom Editor.
Note: you should also fork and clone the pg code and Open Problem Library.
mkdir /opt/webwork/courses
cd /opt/webwork/webwork2/courses.dist
cp *.lst /opt/webwork/courses/
rsync -a modelCourse /opt/webwork/courses/
mkdir /opt/webwork/libraries
cd /opt/webwork/libraries/
git clone https://github.com/openwebwork/webwork-open-problem-library.git
brew install mysql
and to start it:
mysql.server start
To test that it installed, type mysql -uroot
and you should see:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.11 Homebrew
or something similar. To set up WeBWorK database:
mysql> CREATE DATABASE webwork;
mysql> CREATE USER 'webworkWrite'@'localhost' IDENTIFIED BY 'XXXXXX';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, LOCK TABLES ON webwork.* TO 'webworkWrite'@'localhost';
mysql> exit
Bye
$
where XXXX is your database password. You will need this later.
Type
check_modules
and install any (using cpanm
) that are not installed.
Create local versions of each of the configuration files:
cd /opt/webwork/webwork2/conf
cp site.conf.dist site.conf
cp webwork.apache2.4-config.dist webwork.apache2.4-config
cp localOverrides.conf.dist localOverrides.conf