Not quite ready, but anyone trying the Beta at this stage will probably
[moodle.git] / doc / install.html
blob34e523233275e287d27ebe3c88650b15ba9af015
1 <HEAD>
2 <TITLE>Moodle Docs: Installation</TITLE>
3 <LINK REL="stylesheet" HREF="../theme/standard/styles.php" TYPE="TEXT/CSS">
4 </HEAD>
6 <BODY BGCOLOR="#FFFFFF">
7 <H2>Installing Moodle</H2>
8 <P>This guide explains how to install Moodle for the first time. It goes into some detail
9 about some of the steps, in order to cover the wide variety of small differences between
10 web server setups, so this document may look long and complicated. Don't be put off by this
11 - I usually set Moodle up in a few minutes!</P>
12 <P>Take your time and work through this document carefully - it will save you time later on.</P>
13 <P>Sections in this document:</P>
14 <OL>
15 <LI><A HREF="#requirements">Requirements</A></LI>
16 <LI><A HREF="#downloading">Download</A></LI>
17 <LI><A HREF="#site">Site structure</A></LI>
18 <LI><A HREF="#data">Create a data directory</A></LI>
19 <LI><A HREF="#database">Create a database</A></LI>
20 <LI><A HREF="#webserver">Check web server settings</A></LI>
21 <LI><A HREF="#config">Edit config.php</A></LI>
22 <LI><A HREF="#admin">Go to the admin page</A></LI>
23 <LI><A HREF="#cron">Set up cron</A></LI>
24 <LI><A HREF="#course">Create a new course</A></LI>
25 </OL>
26 <H3><A NAME="requirements"></A>1. Requirements</H3>
27 <blockquote>
28 <p>Moodle is primarily developed in Linux using PHP, Apache and MySQL, and regularly
29 tested with PostgreSQL and in Windows XP and Mac OS X environments.</p>
30 <p>All you should need are:</p>
31 <ol>
32 <li>a working installation of <A HREF="http://www.php.net/">PHP</A> (version
33 4.1.0 or later), with the following features enabled (most PHP installations
34 these days will have all of these):
35 <ul>
36 <LI>JPEG and/or PNG image editing support via the <A HREF="http://www.boutell.com/gd/">GD library</A></li>
37 <LI>Sessions support</LI>
38 <LI>File uploading allowed</LI>
39 </UL>
40 </LI>
41 <li>a working database server: <A HREF="http://www.mysql.com/">MySQL</A> or <A HREF="http://www.postgresql.org/">PostgreSQL</A> are recommended. (MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 or ODBC are also theoretically supported but will require you to manually set up the database tables).</li>
42 </ol>
43 <p>On a Windows platform, the quickest way to satisfy these requirements is
44 to download <A HREF="http://www.foxserv.net/">FoxServ</A>,
45 or <A HREF="http://www.easyphp.org/">EasyPHP</A> which will install Apache,
46 PHP, and MySQL for you. Make sure you enable the GD module so Moodle can process
47 images - you may have to edit php.ini and remove the comment (;) from this
48 line: 'extension=php_gd.dll'.</p>
50 <p>On Mac OS X I highly recommend the <a href="http://fink.sourceforge.net/">fink</a>
51 project as a way to download easily-maintainable packages for all of this.</p>
53 <p>If you're on Linux or another Unix then I'll assume you can figure all this out for yourself! ;-) </p>
55 </blockquote>
56 <P>&nbsp;</P>
57 <H3><A NAME="downloading"></A>2. Download</H3>
58 <blockquote>
59 <p>There are two ways to get Moodle, as a compressed package and via CVS. These
60 are explained in detail on the download page on <A HREF="http://moodle.com/">http://moodle.com/</A></p>
61 <p>After downloading and unpacking the archive, or checking out the files via
62 CVS, you will be left with a directory called &quot;moodle&quot;, containing
63 a number of files and folders. </p>
64 <p>You can either place the whole folder in your web server documents directory,
65 in which case the site will be located at <B>http://yourwebserver.com/moodle</B>,
66 or you can copy all the contents straight into the main web server documents
67 directory, in which case the site will be simply <B>http://yourwebserver.com</B>.</p>
68 </blockquote>
69 <P>&nbsp;</P>
70 <H3><A NAME="site"></A>3. Site structure</H3>
71 <BLOCKQUOTE>
72 <p>Here is a quick summary of the contents of the Moodle folder, to help get
73 you oriented:</p>
74 <blockquote>
75 <p>config.php - the only file you need to edit to get started<br>
76 version.php - defines the current version of Moodle code<BR>
77 index.php - the front page of the site</p>
78 <ul>
79 <li>admin/ - code to administrate the whole server </li>
80 <li>auth/ - plugin modules to authenticate users </li>
81 <li>course/ - code to display and manage courses </li>
82 <li>doc/ - help documentation for Moodle (eg this page)</li>
83 <li>files/ - code to display and manage uploaded files</li>
84 <li>lang/ - texts in different languages, one directory per language </li>
85 <li>lib/ - libraries of core Moodle code </li>
86 <li>login/ - code to handle login and account creation </li>
87 <li>mod/ - all Moodle course modules</li>
88 <li>pix/ - generic site graphics</li>
89 <li>theme/ - theme packs/skins to change the look of the site.</li>
90 <li>user/ - code to display and manage users</li>
91 </ul>
92 <p>&nbsp;</p>
93 </blockquote>
94 </BLOCKQUOTE>
95 <H3><A NAME="data"></A>4. Create a data directory</H3>
96 <blockquote>
97 <p>Moodle will also need some space on your hard disk to store uploaded files,
98 such as course documents and user pictures.</p>
100 <p>Create a directory for this purpose somewhere. For security, it's best that
101 this directory is NOT accessible directly via the web. The easiest way to do this
102 is to simply locate it OUTSIDE the web directory, otherwise protect it
103 by creating a file in the data directory called .htaccess, containing this line:
104 <blockquote>
105 <PRE>deny from all</PRE>
106 </blockquote>
108 <p>To make sure that Moodle can save uploaded files in this directory, check that
109 the web server software (eg Apache) has permission to write
110 to this directory. On Unix machines, this means setting the owner of the directory
111 to be something like &quot;nobody&quot; or &quot;apache&quot;.</p>
113 <p>On many shared hosting servers, you will probably need to restrict all file access
114 to your "group" (to prevent other webhost customers from looking at or changing your files),
115 but provide full read/write access to everyone else (which will allow the web server
116 to access your files). Speak to your server administrator if you are having
117 trouble setting this up securely.</p>
119 </blockquote>
120 <P>&nbsp;</P>
121 <H3><A NAME="database"></A>5. Create a database</H3>
122 <blockquote>
123 <p>You need to create an empty database (eg "moodle") in your database system
124 along with a special user (eg "moodleuser") that has access to that database
125 (and that database only). You could use the "root" user if you wanted to, but
126 this is not recommended for a production system: if hackers manage to discover
127 the password then your whole database system would be at risk, rather than
128 just one database.
129 </p>
130 <p>Example command lines for MySQL: </p>
131 <PRE>
132 # mysql -u root -p
133 > CREATE DATABASE moodle;
134 > GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON moodle.*
135 TO moodleuser@localhost IDENTIFIED BY 'yourpassword';
136 > quit
137 # mysqladmin -p reload
138 </PRE>
139 <p>Example command lines for PostgreSQL: </p>
140 <PRE>
141 # su - postgres
142 > psql -c "create user moodleuser createdb;" template1
143 > psql -c "create database moodle;" -U moodleuser template1
144 > psql -c "alter user moodleuser nocreatedb;" template1
145 </PRE>
146 <p>(For MySQL I highly recommend the use of <a href="http://phpmyadmin.sourceforge.net/">phpMyAdmin</a>
147 to manage your databases).</p>
148 <p>As of version 1.0.8, Moodle now supports table prefixes, and so can safely share
149 a database with tables from other applications.</p>
150 </blockquote>
151 <P>&nbsp;</P>
152 <H3><A NAME="webserver" id="webserver"></A>6. Check your web server settings</H3>
153 <blockquote>
154 <p>Firstly, make sure that your web server is set up to use index.php as a default
155 page (perhaps in addition to index.html, default.htm and so on).</p>
156 <p>In Apache, this is done using a DirectoryIndex parameter in your httpd.conf
157 file. Mine usually looks like this:</p>
158 <blockquote>
159 <pre><strong>DirectoryIndex</strong> index.php index.html index.htm </pre>
160 </blockquote>
161 <p>Just make sure index.php is in the list (and preferably towards the start
162 of the list, for efficiency).</p>
163 <p>Secondly, Moodle requires a number of PHP settings to be active for it to
164 work. <B>On most servers these will already be the default settings.</B>
165 However, some PHP servers (and some of the more recent PHP versions) may
166 have things set differently. These are defined in PHP's configuration
167 file (usually called php.ini):</p>
168 <blockquote>
169 <pre>file_uploads = 1
170 magic_quotes_gpc = 1
171 short_open_tag = 1
172 session.auto_start = 0
173 </pre>
174 </blockquote>
175 <p>If you don't have access to httpd.conf or php.ini on your server, or you
176 have Moodle on a server with other applications that require different
177 settings, then you can OVERRIDE all of the default settings.
179 <p>To do this, you need to create a file called <B>.htaccess</B> in Moodle's
180 main directory that contains definitions for these settings.
181 This only works on Apache servers and only when Overrides have been allowed.
182 <BLOCKQUOTE><PRE>
183 DirectoryIndex index.php index.html index.htm
184 php_value magic_quotes_gpc 1
185 php_value file_uploads 1
186 php_value short_open_tag 1
187 php_value session.auto_start 0</BLOCKQUOTE></PRE>
188 <P>You can also do things like define the maximum size for uploaded files:
189 <BLOCKQUOTE><PRE>
190 php_value upload_max_filesize 2M
191 php_value post_max_size 2M
192 </BLOCKQUOTE></PRE>
194 <p>The easiest thing to do is just copy the sample file from lib/htaccess
195 and edit it to suit your needs. It contains further instructions. For
196 example, in a Unix shell:
197 <blockquote>
198 <pre>cp lib/htaccess .htaccess</pre>
199 </blockquote>
201 </blockquote>
202 <p>&nbsp;</p>
203 <H3><A NAME="config"></A>7. Edit config.php</H3>
204 <blockquote>
205 <p>Now you can edit the configuration file, <strong>config.php</strong>, using a
206 text editor. This file is used by all other files in Moodle.</p>
207 <p>To start with, make a copy of config-dist.php and call it config.php. We
208 do this so that your config.php won't be overwritten in case you upgrade Moodle
209 later on. </p>
210 <p>Edit config.php to specify the database details that you just defined (including
211 a table prefix - notice this is REQUIRED for PostgreSQL), as
212 well as the site address, file system directory and data directory.
213 The config file has detailed directions.</p>
214 <p>For the rest of this installation document we will assume your site is at:
215 <u>http://example.com/moodle</u></p>
216 </blockquote>
217 <P>&nbsp;</P>
218 <H3><A NAME="admin"></A>8. Go to the admin page</H3>
219 <blockquote>
220 <p>The admin page should now be working at: <u>http://example.com/moodle/admin</u>.
221 If you try and access the front page of your site you'll be taken there automatically
222 anyway. The first time you access this admin page, you will be presented with
223 a GPL agreement with which you need to agree before you can continue with the setup.</p>
224 <P>(Moodle will also try to set some cookies in your browser. If you have
225 your browser set up to let you choose to accept cookies, then you <B>must</B>
226 accept the Moodle cookies, or Moodle won't work properly.)
227 <p>Now Moodle will start setting up your database and creating tables to store data.
228 Firstly, the main database tables are created. You should see a number of SQL statements followed by
229 status messages (in green or red) that look like this:</p>
230 <blockquote>
231 <p>CREATE TABLE course ( id int(10) unsigned NOT NULL auto_increment, category
232 int(10) unsigned NOT NULL default '0', password varchar(50) NOT NULL default
233 '', fullname varchar(254) NOT NULL default '', shortname varchar(15) NOT
234 NULL default '', summary text NOT NULL, format tinyint(4) NOT NULL default
235 '1', teacher varchar(100) NOT NULL default 'Teacher', startdate int(10)
236 unsigned NOT NULL default '0', enddate int(10) unsigned NOT NULL default
237 '0', timemodified int(10) unsigned NOT NULL default '0', PRIMARY KEY (id))
238 TYPE=MyISAM</p>
239 <p><FONT COLOR="#006600">SUCCESS</FONT></p>
240 <p>...and so on, followed by: <FONT COLOR="#FF0000">Main databases set up
241 successfully</FONT>. </p>
242 </blockquote>
243 <p>If you don't see these, then there must have been some problem with the database
244 or the configuration settings you defined in config.php. Check that PHP isn't
245 in a restricted "safe mode" (commercial web hosts often have safe mode turned
246 on). You can check PHP variables by creating a little file containing &lt?
247 phpinfo() ?&gt and looking at it through a browser. Check all these and try
248 this page again.</p>
249 <p>Scroll down the very bottom of the page and press the &quot;Continue&quot;
250 link.</p>
251 <p>Next you will see a similar page that sets up all the tables required by
252 each Moodle module. As before, they should all be green.</p>
254 <p>Scroll down the very bottom of the page and press the &quot;Continue&quot;
255 link.</p>
257 <p>You should now see a form where you can define more configuration variables
258 for your installation, such as the default language, SMTP hosts and so on.
259 Don't worry too much about getting everything right just now - you can always
260 come back and edit these later on using the admin interface. Scroll down
261 to the bottom and click &quot;Save changes&quot;.</p>
263 <p>If (and only if) you find yourself getting stuck on this page or the next
264 page, unable to continue, then your server probably has what I call the
265 "buggy referrer" problem. This is easy to fix: just edit
266 your config.php and set the variable buggy_referrer to <i>true</i>, then
267 try the page again.</p>
269 <p>The next page is a form where you can define parameters for your Moodle site and the
270 front page, such as the name, format, description and so on.
272 Fill this out (you can always go back and change these later) and then press
273 &quot;Save changes&quot;.</p>
275 <p>Finally, you will then be asked to create a top-level administration user
276 for future access to the admin pages. Fill out the details with your own name,
277 email etc and then click &quot;Save changes&quot;. Not all the fields are
278 required, but if you miss any important fields you'll be re-prompted for them.
279 </p>
280 <blockquote>
281 <blockquote>
282 <blockquote>
283 <blockquote>
284 <blockquote>
285 <p><strong>Make sure you remember the username and password you chose
286 for the administration user account, as they will be necessary to
287 access the administration page in future.</strong></p>
288 </blockquote>
289 </blockquote>
290 </blockquote>
291 </blockquote>
292 </blockquote>
293 <p>Once successful, you will be returned to the main admin page, which contain
294 a number of links arranged in a menu (these items also appear on the home
295 page when you are logged in as the admin user). All your further administration
296 of Moodle can now be done using this menu, such as:</p>
297 <ul>
298 <li>creating and deleting courses</li>
299 <li>creating and editing user accounts</li>
300 <li>administering teacher accounts</li>
301 <li>changing site-wide settings like themes etc</li>
302 </ul>
303 </blockquote>
304 <P>&nbsp;</P>
305 <H3><A NAME="cron"></A>9. Set up cron</H3>
306 <blockquote>
307 <p>Some of Moodle's modules require continual checks to perform tasks. For example,
308 Moodle needs to check the discussion forums so it can mail out copies of posts
309 to people who have subscribed.</p>
310 <p>The script that does all this is located in the admin directory, and is called
311 cron.php. However, it can not run itself, so you need to set up a mechanism
312 where this script is run regularly (eg every five minutes). This provides
313 a &quot;heartbeat&quot; so that the script can perform functions at periods
314 defined by each module.</p>
315 <P>Note that the machine performing the cron <B>does not need to be the same
316 machine that is running Moodle</B>. For example, if you have a limited web hosting
317 service that does not have cron, then you can might choose to run cron on another
318 server or on your home computer. All that matters is that the cron.php file is
319 called every five minutes or so.</p>
320 <p>First, test that the script works by running it directly from your browser:</p>
321 <blockquote>
322 <PRE>http://example.com/moodle/admin/cron.php</PRE>
323 </blockquote>
324 <p>Now, you need to set up some of way of running the script automatically and
325 regularly. </p>
326 <H4> Running the script from a command line</H4>
327 <p>You can call the page from the command line just as you did in the example
328 above. For example, you can use a Unix utility like 'wget':</p>
329 <blockquote>
330 <PRE>wget -q -O /dev/null http://example.com/moodle/admin/cron.php</PRE>
331 </blockquote>
332 <p>Note in this example that the output is thrown away (to /dev/null).</p>
333 <p>The same thing using lynx:</p>
334 <blockquote>
335 <pre>lynx -dump http://example.com/moodle/admin/cron.php &gt; /dev/null</pre>
336 </blockquote>
337 <p>Alternatively you could use a standalone version of PHP, compiled to be run
338 on the command line. The advantage with doing this is that your web server
339 logs aren't filled with constant requests to cron.php. The disadvantage is
340 that you need to have access to a command-line version of php.</p>
341 <blockquote>
342 <PRE>/opt/bin/php /web/moodle/admin/cron.php
345 (Windows) C:\apache\php\php.exe C:\apache\htdocs\moodle\admin\cron.php
347 </PRE>
348 </blockquote>
349 <h4>Automatically running the script every 5 minutes</h4>
350 <p>On Unix systems: Use <B>cron</B>. Edit your cron settings from the commandline
351 using &quot;crontab -e&quot; and add a line like:</p>
352 <blockquote>
353 <PRE>*/5 * * * * wget -q -O /dev/null http://example.com/moodle/admin/cron.php</PRE>
354 </blockquote>
355 <p>On Windows systems: The simplest way is to use my package <A TITLE="Click to download this package (150k)" HREF="http://moodle.com/download/moodle-cron-for-windows.zip">moodle-cron-for-windows.zip</A>
356 which makes this whole thing very easy. You can also explore using the built-in
357 Windows feature for "Scheduled Tasks".</p>
358 </p>
359 </blockquote>
360 <H3><A NAME="course"></A>10. Create a new course</H3>
361 <blockquote>
362 <p>Now that Moodle is running properly, you can create a course. </p>
363 <p>Select &quot;Create a new course&quot; from the Admin page (or the admin
364 links on the home page).</p>
365 <p>Fill out the form, paying special attention to the course format. You don't
366 have to worry about the details too much at this stage, as everything can
367 be changed later by the teacher.</p>
368 <p>Press &quot;Save changes&quot;, and you will be taken to a new form where
369 you can assign teachers to the course. You can only add existing user accounts
370 from this form - if you want to create a new teacher account then either ask
371 the teacher to create one for themselves (see the login page), or create one
372 for them using the &quot;Add a new user&quot; on the Admin page.</p>
373 <p>Once done, the course is ready to customise, and is accessible via the &quot;Courses&quot;
374 link on the home page.</p>
375 <p>See the &quot;<A HREF="teacher.html">Teacher Manual</A>&quot; for more details
376 on course-building.</p>
377 </blockquote>
378 <P>&nbsp;</P>
379 <P ALIGN="CENTER"><FONT SIZE="1"><A HREF="." TARGET="_top">Moodle Documentation</A></FONT></P>
380 <P ALIGN="CENTER"><FONT SIZE="1">Version: $Id$</FONT></P>
382 </BODY>