Step-by-step Guide for Installing Moodle on Mac OS X 10.4 Client
Note: You are currently viewing documentation for Moodle 2.3. Up-to-date documentation for the latest stable version is available here: Step-by-step Guide for Installing Moodle on Mac OS X 10.4 Client.
These instructions were used to install PHP 5.1.2, MySQL 5.0.18 and Moodle with Mac OS 10.4.5 on a standard client Mac (not server version) to be used as a production server. Note that this procedure is more secure than the one-step Moodle4Mac package which is intended for a quick personal install. Moodle4Mac is not for public production use, unless you secured it following special instructions or the MAMP Pro package. The following procedure, however, uses the standard Apache 1.3 which comes on every Mac with OS X. This changes with Mac OS X 10.5, which introduces Apache 2.0 thoroughly integrated into the Mac server.
Note 1: These instructions were prepared by Don Hinkelman, on 20 March 2006 and changes may have occurred. 90% of instructions use a simple point-and-click interface (GUI), but occasionally you will need to open the Terminal (in Utilities folder) to type a command line. To complete all of these steps, I estimate it will take the following amount of time.
- 2 hours >> an experienced setup person
- 4 hours >> an adventuresome novice
- 6÷ hours >> a typical "guy" who never asks for help--should have gone earlier to the moodle.org Installation forums.
Note 2: OS X does not allow MySQL to directly address the kernal, as Linux can do, so in versions 10.4 and under, speed is much slower than with a Linux server. Also a Linux server setup often includes a PHP accelerator which can increase Moodle speeds 5-10x.
Note 3: Due to speed issues I have noted above, I will likely not be upgrading my server to OS X 10.5. However if you test out a Leopard server, please report your findings here or on the "Servers" forums of moodle.org.
Step 1: Prepare your Server
a. Choose an old or new Mac with OS X 10.4 Tiger. This procedure was done on a 933mhz single processor PowerMac.
b. Get a global IP address and a domain name assigned to your server. If you don't want to make a public production server, use the one-step Moodle4OSX download and forget these instructions. :-)
c. Turn on Apache (go to System Preferences >> Sharing >> Services, and then click "Personal Web Sharing" to "On".)
d. Turn off energy saving: Go to System Preferences >> Energy Saver and set the computer sleep time to "Never". Uncheck the hard disk sleep box as well.
e. Download Tinkertool to turn on hidden files. Mac OS X normally hides many files in the system from ordinary users. This includes Apache and other files we will edit in later steps. In order to verify where a file or folder is, use Tinkertool to "show hidden files".
f. Upgrade your Mac OSX to the most recent version and include the most current Security Releases. After you you start running your Moodle server, you may not want to do any more OSX version updates, as the updates often patch Apache and break the whole installation, requiring a reinstall procedure.
Step 2: Install PHP
a. You can install PHP 5.4 by pasting this one line into your terminal:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4
Step 3: Install MySQL
a. Go to the main MySQL Download site and download MySQL standard version 5.0.18 (or later) for the Mac OS X (either PowerPC or x86) version that fits your machine. http://dev.mysql.com/downloads/mysql/5.0.html
b. Click the install package and follow instructions. Click the MySQLStartupItem package and follow instructions.
c. Make a new folder in /Library called "PreferencePanes" (unless already there). Drag the MySQL.prefPane file into that folder. Restart your computer. Click on the System Preferences of OS X. You now see a preference pane active at the bottom of the System Preferences. When you open it, you should see that MySQL is "running". You should make sure the checkbox for automatic MySQL startup is checked.
Step 4: Make a Secure Database for Moodle
a. Go to Terminal and make a password for the MySQL root user. This is an important security point.
/usr/local/mysql/bin/mysqladmin -u root password new_password_here
b. Go to Terminal and make a database for moodle, you might call, "moodle", and a mysql user you might call, "moodleuser". First, type the following in Terminal to enter the MySQL monitor.
/usr/local/mysql/bin/mysql -u root -p
c. Inside MySQL monitor, you first make a database with the first line below, then make a new user and password for using that database, then "flush" and "quit". These are important for making a secure setup.
mysql> CREATE DATABASE moodle;
mysql> ALTER DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'anotherpassword';
mysql> flush privileges;
Step 5: Install Moodle
a. Go to the Moodle Downloads page, download the version you want, and unzip it.
b. Move the moodle folder to this location: /Library/WebServer/Documents/moodle This is for the moodle program and will be accessible to the public. Then create another folder called "moodledata" and put it in an inaccessable location such as /Library/WebServer/moodledata or another non-public area.
c. Set permissions. Here are some easy terminal commands that you can type in to setup permissions for your site. A nice side benefit is that this will allow you to use moodle's setup script to create config.php for you. All of them use "sudo" to attain root access for the task. When you use sudo you will be prompted for a password - use the password of the user you have logged in to the Finder as. This first command sets the owner of your moodledata directory to "www" and the group to "admin". The admin group is any user on your local system that has administrator privs. The www user is the user that the apache web server accesses the file system as.
sudo chown www:admin /Library/WebServer/moodledata/
You want to ensure that the apache user and local admins have access to read and write inside the moodledata folder. This next command opens access up completely to the www user and the admin group and make the folder unreadable by other non-admin users of your system.
sudo chmod 770 /Library/WebServer/moodledata
This next command recursively sets the entire contents of your moodle install directory to have owner "www" and group "admin". -R means "recurse" - which will drill down through the contents of moodledata if there is anything there.
sudo chown -R www:admin /Library/WebServer/Documents/moodle/
Since you have now given ownership of the moodle install directory away to another user you will want to ensure that you, as a local admin, can modify the contents of the moodle installation folder. This command allows anyone in the admin group to add files to the moodle folder structure and edit the contents of files. (g+w means group add write - see man chmod)
sudo chmod -R g+w /Library/WebServer/Documents/moodle
d. Run the Moodle installation script. Type the following URL into your browser (use Firefox, Safari has a few incompatibilities with Moodle).
In this script, you will probably need to adjust the Data Directory. Delete part of path that says "Documents", to match the exact path where you put the "moodledata" folder. If you are installing Moodle ver. 1.6, you may get this error message, "The selected database is running under a non-recommended encoding. Use one that is unicode...". I was able to solve this problem later, by going to the main Moodle Admin page and clicking on the Unicode Migration button near the top.
Step 6: Make a Cron Job
Several Moodle functions require periodic actions called "cron jobs" (such as sending out email messages from forums). To make a cron job, I downloaded Cronnix, http://www.macupdate.com/info.php/id/7486, a GUI interface for editing the crontab in Mac OS X. In Cronnix, I opened a "system" crontab (not user) and set the schedule to: */5 * * * (min= 5, hour = *, Mday = *, month = *, Wday = all). And then inserted the following line into the "command" box as per Martin’s suggestion…
/usr/bin/curl -s -o /dev/null http://myservername/moodle/admin/cron.php
Step 7: Turn on the Postfix Mail Server
The mail server in OS X is called Postfix. Although it is ready to use, it is not unconditionally activated. To turn it on constantly, download the freeware called "WitiSMTP" and turn on the outgoing mail server. In WitiSMTP, you just click on "Enable Postfix..." and then go into your Mail application >> Preferences >> Accounts to rename the SMTP mail server as "localhost".
Step 8: Adjust PHP and Moodle Settings
a. Get a text editor such as the free TextWrangler, and open the following files to make typical adjustments.
b. Change PHP settings. First, raise the PHP memory limit. Moodle recommends a memory limit of 16M, not the default 8M. To do this, find the php.ini file (after you used Tinkertool to reveal hidden files). Find the line that says php_value memory_limit and change the value from 8M to 16M. Second, raise the limit for file uploads. The default limit with this Apple setup seems to be 2mb or 8mb, which is very small for course uploads, large documents, and multi-media files. Raise it to 20MB or higher, and you can adjust limits inside Moodle modules later. I raised my setup to 80M, in order to upload large courses, such as the California State Introducation to Moodle course (67mb). To do this, go to the php.ini file at this path: /usr/local/php5/lib/php.ini and scan through the file to find two more lines--each in a different spot. Change the defaults to the following:
php_value memory_limit 16M post_max_size 80M upload_max_filesize 80M
Remember, you as the administrator, can limit uploads in specific modules (such as forums) as well.
[Note: in Apache 2 and possibly other situations, you may have to edit your Apache settings as well] Go to this file: /private/etc/httpd/httpd.conf Open the file in your text editor, and add the following line.
Then restart Apache (or restart your whole server). To increase speed and reduce the OS overhead, do not run any other programs on your OS X server. In fact, log out all users for best performance.
Step 9: Clean Up
Wash coffee cups, toss chewed up pencils, and wipe your desk off. Congratulate yourself on some excellent webmastering. And bask in the glory of having a real Mac server that you know how to easily control and configure. :-)