As I spent a lot of time (who said "wasted" ?) trying to install/configure/upgrade Moodle on Mac Os X Server (and now, macOS Server), I thought I might write somewhere the problems I met and how I worked around some...
Of course: NO MAMP here !
There are documentation here for Mac Os X Server... but old, and maybenot addressing the pb you have right now.
(for 10.5 and 10.6 ... quite old...)
(for 10.8... less old, but still... old... as it's 10.12 when I'm writing this).
If you're on macOS Sierra (10.12) and you go on a moodle 3.1, for instance, your php version would be recent enough... but, if you're on a Mac Pro 2,1, 3,1, or 4,1 (2007 - 2009), you're stuck with El Capitan (10.11). It means you have to upgrade your php... and believe me, it's not *that* easy. Same thing if you're on Sierra and wanna go for moodle 3.3 or + ... you need php7.x ...
First: Apache & PHP
Get this in mind: macOS Server is NOT macOS. It means the tutos and infos you'll find on the net will not be accurate. Believe me, I spent weeks (yeah, really, weeks...) trying to figure out why all these tutos lead to a dead end.
Apache server is controlled by the server app, where you can activate php by clicking on the right box. But your php version is too old or you want to update it anyway, let's say, to php 7.1. Thing is: you CAN NOT update the built in php.
There several ways to do so, with homebrew, git, curl, etc... let's go to the terminal and then, enter this:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.1
that will install php71 in /local/
if you want to use homebrew, I'm gonna take as done that you already installed it and than, in terminal:
that will install php71 in /local/Cellar/
If you type php -v in the terminal, it will probably tell you that you now have php 7.1, so, after that, you might think you're done... but, ahahahahaha, nope. Apple super-murphy-powa. Try to launch a phpinfo and you'll find out that the apache server is still using the built in php (5.x version). Weird ? Yup.
So now, you need to change the .conf used by the apache on macOS server... WHICH IS NOT THE SAME than macOS ! Weird ? Yupyup. It's in /Library/Server/Web/Config/apache2/ !! So, let's use the terminal again (don't modify .conf or .ini file using TextEdit or Office... you'll have permissions issues after that...) with sudo nano (or sudo pico, I don't really see the difference)
sudo nano /Library/Server/Web/Config/apache2/httpd_server_app.conf
using Ctrl + W, search for php5_module. If you have checked the php bow, in the Server app (in Web Sharing section), it's uncommented (meaning: it will be used)... if you didn't, it will be commented with a # at the beginning (meaning: not used).
So, I think you got it: comment it (if it's not) and unchecked the php box in Server app (and don't checked it ever again).
Under the php5_module line, add this one:
LoadModule php7_module /usr/local/php5-7.1.4-20170506-100436/libphp7.so
(in the case you updated with curl, previously)...
If you used homebrew... OR if you used curl but the php version was updated (which is highly likely)... the path will not be the same... doesn't matter.. just place the right path instead of /usr/local/php5-7.1.4-20170506-100436/libphp7.so
(for Homebrew, that might be something like: /usr/local/Cellar/php71/7.x.x.x/libexec/apache2/libphp7.so )
then, at the end of the .conf file, you have a block starting with IfModule php5_module... after this block, add the php7 handler:
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
then save with Ctrl + O, close the .conf file with Ctrl + X and, even if it's necessary, feel free to reboot...
You'll want to change something in the php.ini to activate OPCache and change some values (php memory, this kind of stuff, as adviced in Moodle documentation)
but beware then: the php.ini that will be used is NOT the one you might think... check that using a phpinfo. How to ?
Terminal again. Type in:
sudo nano /Library/Server/Web/Data/Sites/Default/info.php
as it probably doesn't exist, it will create one.
<?php phpinfo(); ?>and then save with Ctrl + O, close the file with Ctrl + X and point your browser to localhost/info.php
that should do the trick.
Anyway, you have not one, but several .ini files to check ! For instance, to activate OPCache, it's not the main .ini file (where you can find a line opcache.enable= ) where you will be able to do it... but in the php.d folder, there dozen of .ini... so, to activate POPCache, in the terminal, if you installed with curl, and if it's the same version as previously written:
sudo nano /usr/local/php5-7.1.4-20170506-100436/php.d/20-extension-opcache.ini
The path might not be the exact samething... so, check that and adapt.
Go there: https://dev.mysql.com/downloads/mysql/
and and download the Community Server for Mac ... and install it.
you might have a root password issue... you can fix it using this tuto:
I'd advice to use git to install moodle... It might not be the easiest way for the noob (that I am) but it helps when you want to update/upgrade.
For that, the Moodle 3.3.x documentation is here: https://docs.moodle.org/33/en/Git_for_Administrators
Basically ? Terminal again.
(if your webroot is not there, then change the path accordingly)
git clone git://git.moodle.org/moodle.git
git branch -a
git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE
git checkout MOODLE_33_STABLE
Everything is from the documentation... I just add this here as a way to speed the process ... but anyway, take some time to read the docs. (you know: RTFM ... this kind of stuff)
Of course, you now foresee that, nope cap'tain, it's not enough. we miss something. Permissions.
For once, I don't like using the terminal, but it's basically because I'm a permanent n00b. And everytime I can use a nice GUI that does the trick, I'm gonna use it.
I use BatChModI from Lagentesoft ... I use it to find my moodle directory and then change:
- the owner to _www
- the group to admin with Read, Write permissions
- check the box so BatChMod applies the same perm to EVERYTHING inside.
Yup, that's not subtle and I'm pretty sure a lot of geeks will burn a picture of me for doing so... But that means pictures of me will be hot, very hot... at least for 2 seconds. Not so bad, huh ? Still, it's better than I can be myself anytime !!
Now, as the php version is ok, as My SQL is installed, point your browser to
and follow the instructions.
Place the folder moodledata OUTSIDE on the folder where your site is hosted... for security reason. By default, it's:
Which is fine.. but you can place it on another location, or another volume....
If the installer warns you about permissions, create it by yourself and you can use BatChMod again to make this moodledata folder owner as _www
After the infos about MySQL, moodle will create a config.php ... you'll have to modify it after the whole process.
It installs and everything should be fine... It might ask you to activate OPCache if you didn't. If it says it can't create the config file, because of write access, you missed the first section with BatChMod (see up ahead)
Main problem that remains:
Everything except "site not https" . It's no pb to go on with the install... and this matter needs to be adressed, as I didn't find a proper way to make moodle worked with my ssl website (which is working fine with other website like nextcloud which need php7 and ssl as well)...
Last thing to do:
Now that's it's installed... we need to modify the config file.
sudo nano /Library/Server/Web/Data/Sites/Default/moodle/config.php
Change the url to the one that people will use to access it... and then, again, Ctrl+W to save, Ctrl+X to quit.
But after that, maybe you will not be able to access it from your machine ! You need to edit your host file...
sudo nano /private/etc/hosts
and than, add a line with your url ... like this:
and then, again, Ctrl+W to save, Ctrl+X to quit.
It will say to your browser, when you go to that fancy url, like www.my-moodle-is-better-than-yours.com , in fact, point to my localhost (aka 127.0.0.1). Of course, change the line with YOUR url.
This doesn't cover the rest of the configuration (themes, plug ins, how to setup the whole stuff), the documentation is here for that.
Plus, I do NOT fancy myself as an expert on these topics (mac, php, apache, whatever...). This is mainly to gather, in one place, and for the poor souls that want to moodle on their macOS Server machine... to avoid them the weeks of pain, anger, despair and torture I went thru...
There are still things that don't work (https, for instance... I need help on that) ... and some stuff that may work on moodle linux... or in MAMP/XAMP/LAMP/PAMP/CLAMP (what ? the last one doesn't exist ? hang on !), well, it may doesn't work 100% on macOS Server...
May I add that I'm french...meaning:
- my english may need improvement
- my anger management does needs improvement
- my sense of humour sure needs improvement
So, please, don't be trump on me... (-: