<p>This guide explains how to install Moodle for the first time. For some of these steps it goes into a lot of detail to try and cover the majority of possible
web server setups, so this document may look long and complicated. Don't panic, once you know how to do it you can install Moodle in minutes!</p>
<p>If you have problems please read this document carefully - most common issues are answered in here.
<p>If you are downloading Moodle to your local computer and then uploading it to your web site, it is usually better to upload the whole archive as one file, and then do the unpacking on the server. Even web hosting interfaces like Cpanel allow you to uncompress archives in the "File Manager". </p>
<p>To run the installer script (install.php), just try to access your Moodle main URL using a web browser, or access <strong>http://yourserver/install.php</strong> directly. </p>
<p>(The Installer will try to set a session cookie. If you get a popup warning in your browser make sure you accept that cookie!) </p>
<p>Moodle will detect that configuration is necessary and will lead you through some screens to help you create a new configuration file called <strong>config.php. </strong>At the end of the process Moodle will try and write the file into the right location, otherwise you can press a button to download it from the installer and then upload config.php into the main Moodle directory on the server. </p>
<p>Along the way the installer will test your server environment and give you suggestions about how to fix any problems. For most common issues these suggestions should be sufficient, but if you get stuck, look below for more information about some of common things that might be holding you up. <br/>
<p>The easiest thing to do is just copy the sample file from <strong>lib/htaccess</strong> and edit it to suit your needs. It contains further instructions. For
<p>You need to create an empty database (eg "<em>moodle</em>") in your database system
along with a special user (eg "moodleuser") that has access to that database
(and that database only). You could use the "root" user if you wanted to for a test server, but
this is not recommended for a production system: if hackers manage to discover
the password then your whole database system would be at risk, rather than
just one database. </p>
<p>If you are using a webhost, they will probably have a control panel web interface for you to create your database. </p>
<p>The <strong>Cpanel</strong> system is one of the most popular of these. To create a database in Cpanel, </p>
<ol>
<li>Click on the "<strong>MySQL Databases</strong>" icon.</li>
<li>Type "moodle" in the database field and click "<strong>Add Database</strong>".</li>
<li> Type a username and password (not one you use elsewhere) in the respective fields and click "<strong>Add User</strong>".</li>
<li> Now use the "<strong>Add User to Database</strong>" button to give this new user account "<strong>ALL</strong>" rights to the new database.</li>
<li>Note that the username and database names may be prefixed by your Cpanel account name. When entering this information into the Moodle installer - use the full names.</li>
</ol>
<p>If you have access to Unix command lines then you can do the same sort of thing by typing commands. </p>
<p>Here are some example Unix command lines for MySQL: </p>
<pre>
# mysql -u root -p
> CREATE DATABASE moodle;
> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON moodle.*
TO moodleuser@localhost IDENTIFIED BY 'yourpassword';
> quit
# mysqladmin -p reload
</pre>
<p>And some example command lines for PostgreSQL: </p>
<pre>
# su - postgres
> psql -c "create user moodleuser createdb;" template1
> psql -c "alter user moodleuser nocreatedb;" template1</pre>
</blockquote>
<p> </p>
<h3class="sectionheading"><aname="data"></a>4.3 Creating a data directory </h3>
<blockquote>
<p>Moodle will also need some space on your server's hard disk to store uploaded files, such as course documents and user pictures. </p>
<p>The Moodle installer tries hard to create this directory for you but if it fails then you will have to create a directory for this purpose manually. </p>
<p>For security, it's best that this directory is NOT accessible directly via the web. The easiest way to do this is to simply locate it OUTSIDE the web directory, but if you must have it in the web directory then protect it by creating a file in the data directory called .htaccess, containing this line: </p>
<blockquote>
<pre>deny from all</pre>
</blockquote>
<p>To make sure that Moodle can save uploaded files in this directory, check that the web server software (eg Apache) has permission to read, write and execute in this directory. </p>
<p>On Unix machines, this means setting the owner of the directory to be something like "nobody" or "apache", and then giving that user read, write and execute permissions.</p>
<p>On Cpanel systems you can use the "File Manager" to find the folder, click on it, then choose "Change Permissions". On many shared hosting servers, you will probably need to restrict all file access to your "group" (to prevent other webhost customers from looking at or changing your files), but provide full read/write access to everyone else (which will allow the web server to access your files). </p>
<p>Speak to your server administrator if you are having trouble setting this up securely. In particular some sites that use a PHP feature known as "Safe Mode" may <em>require</em> the administrator to create this directory properly for you. </p>
<p>Once the basic <strong>config.php</strong> has been correctly created in the previous step, trying to access the front page of your site will take you the "admin" page for the rest of the configuration.</p>
<p>The first time you access this admin page, you will be presented with
a GPL "shrinkwrap" agreement with which you <strong>must</strong> agree before you
<pclass="style3">If you don't see these, then there must have been some problem with the database
or the configuration settings you defined in config.php. Check that PHP isn't
in a restricted "Safe Mode" (commercial web hosts sometimes have safe mode
turned on). You can check PHP variables by creating a little file containing <strong><?php phpinfo() ?></strong> and looking at it through a browser. Check all these and
<pclass="style3">If (and only if) you find yourself getting stuck on this page, unable to
continue, then your server probably has what I call the "buggy referrer" problem.
This is easy to fix: just turn off the "secureforms" setting, then
try to continue again.</p>
</blockquote>
<p>Next you will see more pages that print lots of status messages as they set up all the tables required by the various Moodle module. As before, they should all be <fontcolor="#006600">green</font>.</p>
<p>Scroll down the very bottom of the page and press the "Continue" link.</p>
<p>The simplest way is to use this little package <ahref="http://moodle.org/download/modules/moodle-cron-for-windows.zip"title="Click to download this package (150k)"target="_blank"><strong>moodle-cron-for-windows.zip</strong></a> which makes this whole thing very easy by installing a small Windows service. Run it and forget about it!</p>
<p> Your web-based control panel may have a web page that allows you to set up this cron process. For example, on Cpanel system, look for a button called "Cron jobs". In there you can put the same sort of Unix commands as listed below. </p>
<p>There are different command line programs you can use to call the page from the command line. Not all of them may be available on a given server.</p>
<p>For example, you can use a Unix utility like 'wget':</p>
<p> All that Cpanel does is provide a web interface to a Unix utility known as crontab. If you have a command line, you can set up crontab yourself using the command:</p>
<blockquote>
<pre>crontab -e</pre>
</blockquote>
<p>and then adding one of the above commands like:</p>
<palign="center"><strong>Happy exploring and happy Moodling!</strong></p>
<palign="center"><strong>If you like Moodle, please consider <ahref="http://moodle.org/donations/"target="_blank">donating</a> to help us cover our costs! </strong></p>