# Installing Apache, MySQL and PHP

> Moodle is written in a scripting language called PHP, and stores most of its data in a database. The database we recommend is MySQL. Before installing Moodle you must have a working PHP installation and a working database to turn your computer into a functional web server platform. These packages can be tricky to set up for average computer users, so this page has been written to try to make this process as simple as possible for different platforms:

> - Hosting Service
> - Mac OS X
> - Redhat Linux
> - Windows

> ### Hosting Service

> > Unfortunately hosting services vary quite a lot in the way they work. Some will even install Moodle for you.

> > Most will offer a web-based control panel to control your site, create databases and set up cron. Some may also offer terminal access via ssh, so that you can use the command shell to do things.

> > You should work your way through the Installation guide and take each step at a time. Ask your hosting provider if you get stuck.

> ### Mac OS X

> > The easiest way to do this is use the Apache server that Apple provides, and add PHP and MySQL using Marc Liyanage's packages. Both of the pages below come with good instructions that we won't duplicate here:

> > > PHP: Download from here: http://www.entropy.ch/software/macosx/php/

> > > MySQL: Download here: http://www.entropy.ch/software/macosx/mysql/

> > Once these are installed the standard Installation guide should be fairly straightforward.

> > A more detailed walkthrough is here: http://moodle.org/wiki/index.php/InstallingMoodle

> ### Redhat Linux

> > You should install all available RPM packages for Apache, PHP and MySQL. One package that people frequently forget is the php-mysql package which is necessary for PHP to talk to MySQL.

> > Once these are installed the standard Installation guide should be fairly straightforward.

> > A more detailed walkthrough is here: http://moodle.org/wiki/index.php/InstallingMoodle

> ### Windows

> > The easiest way to do this is use EasyPHP, a package that bundles all the software you need into a single Windows application. Here are the steps from start to finish:

> > 1. Firstly, if you have ever installed MySQL before (even as part of another package), uninstall it all, delete all the MySQL files and make sure you delete c:\my.cnf and c:\windows\my.ini.You might want to do a search and delete ANY file called my.cnf or my.ini.
> > 2. If you've ever installed PHP before delete any files called php4ts.dll from around your Windows directory, as well as any files called php.ini.
> > 3. Download EasyPHP from here: http://www.easyphp.org/telechargements/dn.php?F=easyphp1-7 (approx 10 Mb)
> > 4. Run the downloaded file: easyphp1-7_setup.exe. The installation process is in French but is otherwise much like installing any other Windows program - I advise accepting the defaults and letting it all install. Note that "Suivant" means Next and "Oui" means Yes.
> > 5. At the end of the install leave the checkbox selected to "Lancer EasyPHP" (Start EasyPHP) and hit the 'Terminer" button. You might be taken to a information web page which you can safely ignore.
> > 6. If all went well - congratulations! Apache, PHP and MySQL are all installed and running! You should see a black E in your toolbar tray. You can right click on it to get a menu which will let you control the running programs.
> > 7. Some things may be in French and you may prefer English. You can download this file http://www.easyphp.org/telechargements/dn.php?F=indexUS_1.7 which contains English versions of www and home folder in the EasyPHP1-7 folder. These can be copied over the default files.
> > 8. The next thing you need to do is to set up a database for Moodle to use. Right-click the black E in the toolbar tray and choose Administration, then click DB Management (beside PHPMyAdmin).
> > 9. If asked for a username, use "root" with a blank password. You should see a phpMyAdmin web interface that allows you to create a new databases and user accounts.
> > 10. Create a new database by typing "moodle" into the field and hitting the "Create" button. That was easy!
> > 11. You can also create a new user to access your database if you want. This can be a bit tricky for a first-time user, so you might just want to use the existing user "root" with no password in your Moodle config for now, and fix this later.
> > 12. You're ready to install Moodle! Download the latest release of Moodle from http://moodle.org/download, then unzip the archive.
> > 13. Copy your moodle files into C:\Program Files\EasyPHP\www. You can either copy the entire moodle directory (ie C:\Program Files\EasyPHP\www\moodle) or copy all the contents of the moodle directory. If you choose this second option then you will be able to access your Moodle home page using http://localhost/ instead of http://localhost/moodle/.
> > 14. Make a new empty folder somewhere else for Moodle to store uploaded files in, eg: C:\moodledata
> > 15. Go into your Moodle folder. Make a copy of config-dist.php, and call it config.php
> > 16. Edit config.php using a text editor (Notepad will do, just be careful that it doesn't add unwanted spaces at the end).
> > 17. Put in all your new database info:
> >     $CFG->dbtype = 'mysql';
> >     $CFG->dbhost = 'localhost';
> >     $CFG->dbname = 'moodle';
> >     $CFG->dbuser = 'root';
> >     $CFG->dbpass = '';
> >     $CFG->dbpersist = true;
> >     $CFG->prefix = 'mdl_';
> > 18. And put in all your file paths:
> >     $CFG->wwwroot = 'http://localhost/moodle'; // Use an external address if you know it.
> >     $CFG->dirroot = 'C:\Program Files\EasyPHP\www\moodle';
> >     $CFG->dataroot = 'C:\moodledata';
> > 19. Save config.php - you can ignore the other settings if there are any.
> > 20. You're nearly there now! The rest of the setup is all web-based. Visit http://localhost/moodle/admin/ with your browser to continue the setup via your browser.
> > 21. To use zip files with Moodle (for example the backups use zip) you might need to enable "zlib". You can do this by going to your EasyPHP directory (C:\Program Files\EasyPHP), and running the program phpini.exe in there. Put a mark in the checkbox next to "zlib.dll". Close that window, then go to the black E in your toolbar and right-click it to get a menu - select "Restart" from this menu.
> > 22. Lastly, you need to set up some sort of cron. See the Installation guide for more details on this.

> > If you don't or can't use EasyPHP, here are some a few tips to make sure your PHP is set up correctly and avoid common problems:

> > - Make sure you enable the GD module so Moodle can process images - you may have to edit php.ini and remove the comment (;) from this line: 'extension=php_gd2.dll'.
> > - Make sure you enable the Zlib module so that you can create and unpack zip files from within Moodle.
> > - Make sure sessions is turned on - you may have to edit php.ini and fix the directory for session.save_path - instead of the default "/tmp" use a Windows directory like "c:/temp".

Moodle Documentation

Version: $Id$