Installing Moodle on 5.0-Nano: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
mNo edit summary
m (Text replace - "projects/uniformserver" to "projects/miniserver")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<span id="top"></span>
<span id="top"></span>
{| cellpadding="2"
{| cellpadding="2"
|__TOC__||'''Installing Moodle on 5.0-Nano'''
|__TOC__||'''Installing Moodle on 5-Nano Series'''
|}
|}
'''Introduction'''
'''Introduction'''


This step-by-step guide shows how to install Moodle on Uniform Server V5.0-Nano. In addition shows how to resolve fixed paths allowing Moodle to be run from a USB memory stick.
This step-by-step guide shows how to install Moodle on Uniform Server V5-Nano. In addition shows how to resolve fixed paths allowing Moodle to be run from a USB memory stick.


Windows does not support true cron jobs however V5.0-Nano has an integrated portable Cron catering for both hard drive and USB memory stick installations.   
Windows does not support true cron jobs however V5-Nano has an integrated portable Cron catering for both hard drive and USB memory stick installations.   


== Pre-Installation ==
== Pre-Installation ==
Line 16: Line 16:


# '''A)''' Create a new folder named '''moodle_b''' (Can be any name)
# '''A)''' Create a new folder named '''moodle_b''' (Can be any name)
# Extract a new copy of Uniform Server V5.0-Nano to this folder<br>(Double click on file to extract).  
# Extract a new copy of Uniform Server V5.5-Nano to this folder<br>(Double click on file to extract).  


'''''Download Moodle'''''  
'''''Download Moodle'''''  
Line 275: Line 275:


Admin login
Admin login
* Username: ''' boss'''
* Username: '''admin'''
* Password: '''fred123'''
* Password: '''UniServer-54'''
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


Line 291: Line 291:
UniServer\www\moodle\'''config.php'''  
UniServer\www\moodle\'''config.php'''  


Its a small file locate the following three lines (yours may be slightly different):
Its a small file locate the following lines (yours may be slightly different):
{|
|-
|
<pre>
<pre>
$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = 'root';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';
$CFG->wwwroot  = 'http://localhost/moodle';
$CFG->wwwroot  = 'http://localhost/moodle';
$CFG->dirroot  = 'C:\moodle_b\UniServer\www\moodle';
$CFG->dirroot  = 'C:\moodle_b\UniServer\www\moodle';
$CFG->dataroot  = 'C:\moodle_b\UniServer/moodledata';
$CFG->dataroot  = 'C:\moodle_b\UniServer/moodledata';
</pre>
$CFG->admin    = 'admin';
The hard coded paths start with '''C:''' followed by a list of folders to the Moodle installation these hard coded paths prevent portability. Another problem, first line assumes you are running servers on localhost and standard port 80 this becomes an issue if you run [[#Move Servers | '''move servers''']] (multi-server operation) because it changes all ports.  
</pre>  
|}
Second line assumes you are running the MySQL server on standard port 3306.
 
Another problem, eighth line assumes you are running servers on localhost and standard port 80 this becomes an issue if you run [[#Move Servers | '''move servers''']] (multi-server operation) because it changes all ports.


Solution is to let PHP automatically calculate absolute paths and web-root folder.
Hard coded paths start with '''C:''' followed by a list of folders to the Moodle installation these hard coded paths prevent portability.    


Replace the above three lines with the following code:
Solution is to let PHP automatically calculate absolute paths and web-root folder including ports used.
 
Replace the above lines with the following code:
{|
|-
|
<pre>
<pre>
$splitArray  = explode("\\www",__DIR__);  // Split at folder www to
// === MPG Set base path ======================================================
$base         = "$splitArray[0]";         // find drive letter and sub-folders
$path_array = explode("www", dirname( __FILE__ ));  // Split path at www
$base          = "$path_array[0]";            // absolute path to ..UniServer/
// ================================================== MPG End Set base path ===
 
// === MPG Get MYSQL port =====================================================
// Use port from configuration file - because user can change this file
$file_conf  = $base.'usr\\local\\mysql\\my.ini'; // Config file
 
if ($filearray=file($file_conf)) {              // read file into array
foreach ($filearray as $txt) {                // scan array for port
  if(preg_match("/^\s*port\s*=\s*(\d+)/", $txt,$match)){ // check save matches
  $mysql_port =  $match[1];                    // match found save port number
  break;                                      // give up nothing else to do
  }
}
}
else {                                      // failed to read file
echo "Cannot read the file";
}
// ===================================================== END Get MySQL Port ===
 
$CFG->dbtype    = 'mysql';
$CFG->dbhost    = "localhost:$mysql_port";
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = 'root';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';


$root  = 'http://'.getenv("HTTP_HOST").'/moodle';        // Local testing
$root  = 'http://'.getenv("HTTP_HOST").'/moodle';        // Local testing
//$root = 'http://'.GetHostByName($REMOTE_ADDR).'/moodle'; // moving from event to event
//$root = 'http://'.GetHostByName($REMOTE_ADDR).'/moodle'; // moving from event to event


$CFG->wwwroot  = $root;
$CFG->wwwroot  = $root;
$CFG->dirroot  = $base.'\www\moodle';
$CFG->dirroot  = $base.'www\moodle';
$CFG->dataroot  = $base.'\moodledata';
$CFG->dataroot  = $base.'moodledata';
$CFG->admin    = 'admin';


</pre>  
</pre>  
|}
The above change makes Moodle completely portable.
The above change makes Moodle completely portable.


Line 464: Line 514:
* Under '''Plugins'''
* Under '''Plugins'''
* Navigate to sub-folder '''Uniform Server 5-Nano Plugins'''
* Navigate to sub-folder '''Uniform Server 5-Nano Plugins'''
* Download file [http://sourceforge.net/projects/miniserver/files/Plugins/UniServer%2055-Nano%20Plugins/Applications/V55_Moodle/V55_Moodle_l_9_5.exe/download V55_Moodle_l_9_5.exe]
* Download file [http://sourceforge.net/projects/miniserver/files/Plugins/UniServer%2055-Nano%20Plugins/Applications/V55_Moodle/V55_Moodle_l_9_7.exe/download V55_Moodle_l_9_7.exe]


Save this to folder UniServer, to install double click on file. Moodle is pre-configured and ready to go. Check out the read me file for latest information.
Save this to folder UniServer, to install double click on file. Moodle is pre-configured and ready to go. Check out the read me file for latest information.
Line 472: Line 522:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


== MySQL Security ==
The above installation guide and associated downloadable plugin are intended to get the application up and running purely for testing.
If you are intending to put the application on line make sure to read any security advice provided with the application and check providers web site.
More impotently the above installation is an extreme security risk if put online as is. 
Its imperative you secure the MySQL server before putting your servers online.
Please read the following page [[MySQL Security | '''MySQL Security''']] and restrict privileges to any user that has connection access to your server.
'''''[[#top | Top]]'''''
== Summary ==
== Summary ==
Although there are a large number of steps Moodle is easy to install on Uniform Server.
Although there are a large number of steps Moodle is easy to install on Uniform Server.

Latest revision as of 16:11, 17 October 2012

Installing Moodle on 5-Nano Series

Introduction

This step-by-step guide shows how to install Moodle on Uniform Server V5-Nano. In addition shows how to resolve fixed paths allowing Moodle to be run from a USB memory stick.

Windows does not support true cron jobs however V5-Nano has an integrated portable Cron catering for both hard drive and USB memory stick installations.

Pre-Installation

Install Uniform server

  1. A) Create a new folder named moodle_b (Can be any name)
  2. Extract a new copy of Uniform Server V5.5-Nano to this folder
    (Double click on file to extract).

Download Moodle

  1. B) Create a new folder moodle_a (Can be any name its only a temporary folder)
  2. Download the latest version (moodle-weekly-19.zip) of Moodle from Moodle download page
  3. Copy the file dowloaded (moodle-weekly-19.zip) to moodle_a
  4. Unzip moodle-weekly-19.zip into this folder.
    (Right click on file, select extract all, extract to current path.)

Copy files to Uniform Server

  1. C) Expand the folder moodle-weekly-19
  2. D) Copy folder moodle to Uniform Servers's root folder www

Top

Switch to production, start servers

UniServer’s default is to use the production PHP configuration file however you may have switched configuration files during development.

Before installing any applications ensure the production configuration is selected.

Check configuration file:

  1. Start UniTray, in folder UniServer double click on Start.exe tray icon created.
  2. Check configuration: Left click tray icon > Server Status – Top of page php.ini displays either Production or development.
  3. If Production displayed no action required you can start servers.
  4. If development displayed proceed as follows:
  5. Switch to production, Left click tray icon > Advanced > click php.ini switch to Production.

Start Servers:

  • Start Uniform Server. Left click tray icon > click Start UniServer

Top

Create a Moodle Database

Creating the Moodle database is straight forward, tables are automatically inserted during installation

  1. Left click tray icon > click phpMyAdmin - This opens phpMyAdmin in your browser
  2. A) We want to create a new database. Name it moodle (or something easy to remember if you change name make sure you use this name during installation.)
  3. B) Click on Create to create the database

Note:

  • You can start phpMyAdmin from Apanel, start Apanel by typing http://localhost/apanel/ into your browser address bar.
  • From Apanel click on the phpMyAdmin link. (left menu under tools)

Top

Moodle Installation

All that remains is to run the Moodle installer script install.php. Type the following into your browser address bar.

http://localhost/moodle/install.php

Most of the pages display information to proceed to the next page click either next or continue button. Item 4 requires a database user name and password, for a personal installation we are using defaults root and root. The following shows what to expect during installation:

1) Choose a Language: Select your language e.g. English (en) click Next

2) Checking your PHP Settings: passes all click NEXT

Your server should pass all these tests to make Moodle run properly

    PHP version   Pass
  Session Auto Start   Pass
  Magic Quotes Run Time   Pass
  Insecure Handling of Globals   Pass
  Safe Mode   Pass
  File Uploads   Pass
  GD version   Pass
  Memory Limit   Pass

3) Please confirm the locations of this Moodle installation:

  • Web address http://localhost/moodle
  • Moodle Directory C:\moodle_b\UniServer\www\moodle - Grayed out
  • Data Directory C:\moodle_b\UniServer/moodledata

For a default installation of Uniform Server these are correct (will be different for your installation) click Next

4) Database configuration:

    Type:   MySQL(mysql)  
  Host Server:   localhost  
  User:   root -- (Uniform Servers default, enter this)
  Password:   root -- (Uniform Server default, enter this)
  Tables prefix:   mdl_  

Click Next

5) Checking your environment:

Name   Information   Report   Status
unicode       must be installed and enabled   OK
database   mysql   version 4.1.16 is required and you are running 5.1.36   OK
php       version 4.3.0 is required and you are running 5.3.0   OK
php_extension   iconv   should be installed and enabled for best results   OK
php_extension   mbstring   should be installed and enabled for best results   OK
php_extension   curl   should be installed and enabled for best results   OK
php_extension   openssl   should be installed and enabled for best results   OK
php_extension   tokenizer   should be installed and enabled for best results   OK
php_extension   xmlrpc   should be installed and enabled for best results   OK
php_extension   ctype   should be installed and enabled for best results   OK

6) Download language pack Installation: Option to download a language pack NEXT

7) Configuration completed: config.php has been successfully created Continue

8) Copyright notice: Have you read these conditions and understood them? YES

9) Current release information: Moodle 1.9.5+ (Build: 20091126)(leave Unattended operation un-checked): Continue

10) Setting up database: Takes some time wait as the install takes place: Database was successfully updated Continue

11) Setting up module tables: Again wait, Workshop tables have been setup correctly Continue

12) Setting up plugin tables: Truefalse tables have been set up correctly, Continue

13) Upgrading database: Datbase was successfully upgraded Continue

14) Upgrading database: Blocks version is now 2007081300 Continue

15) Setting up block tables: Continue

16) Setting up plugin tables: Paypal tables have been set up correctley Continue

17) Setting up plugin tables: xml and other plugins set up correctly Continue

18) Setting up plugin tables: xml tables have been set up correctly Continue

19) Setting up plugin tables: user tables have been set up correctly Continue

20) Setting up plugin tables: stats tables have been set up correctly Continue

21) Setting up plugin tables: unittest tables have been set up correctly Continue

22) Setup administrator account:

Admin set-up: On this page you should configure your main administrator account which will have complete control over the site. Make sure you give it a secure user name and password as well as a valid email address. You can create more admin accounts later on. Fill in details:

Username: admin
New password UniServer-54
Force password change leave unchecked
First name: Fred
Surname: Smith
Email address: fred@smith.com
Email display: Hide my Email address from everyone
Email activated: This email address is enabled
City/Town: Cambridge
Select acountry: United Kingdom
Timezone: Server's local time
Prefered language: English
Leave rest blank  

Click Update profile

23) Front Page settings:

This page allows you to configure the front page and name of this new site. You can come back here later to change these settings any time using the Administration menus. Fill in details:

  • Full site name: MPG Test
  • Short name: MPG
  • Front page description: Personal installation of Moodle running on Uniform Server 5.0-Nano
  • New settings - Manage authentication: Disabled
  • Click: save changes

24) Finished:

This is your main admin page you can continue setting up Moodle or log out

Note: Steps 22-23 I entered dummy information. You can change this information from admin at any time, however make sure you remember your admin password and name.

Top

Stopping Moodle

  1. Logout from admin
  2. Stop Uniform Server. Left click tray icon > click Stop UniServer - Second menu item from top

Top

Starting Moodle

  1. Start UniTray, in folder UniServer double click on Start.exe tray icon created.
  2. Start Uniform Server. Left click tray icon > click Start UniServer - First menu Item
  3. In your browser address bar type http://localhost/moodle/

Admin login

  • Username: admin
  • Password: UniServer-54

Top

Portability - USB Memory Stick

To run Moodle from a Memory stick, copy the folder UniServer and all its content to whatever drive your memory stick is on.

Note: This process is not fast; writing 104 MB (UniServer plus Moodle) took just over 20 minutes. In the same vain do not expect exceptional performance, Moodle uses a large database hence is slow when run from a memory stick. That said I found it just about acceptable.

Hard Coded path

During installation Moodle uses absolute paths (drive letter and folder path to moodle) and hard wires these into a configuration file. This means you cannot move the installation to another location and expect Moodle to run. A solution to this problem requires modifying Moodle's configuration file config.php.

Open the following file in a text editor:

UniServer\www\moodle\config.php

Its a small file locate the following lines (yours may be slightly different):

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = 'root';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

$CFG->wwwroot   = 'http://localhost/moodle';
$CFG->dirroot   = 'C:\moodle_b\UniServer\www\moodle';
$CFG->dataroot  = 'C:\moodle_b\UniServer/moodledata';
$CFG->admin     = 'admin';

Second line assumes you are running the MySQL server on standard port 3306.

Another problem, eighth line assumes you are running servers on localhost and standard port 80 this becomes an issue if you run move servers (multi-server operation) because it changes all ports.

Hard coded paths start with C: followed by a list of folders to the Moodle installation these hard coded paths prevent portability.

Solution is to let PHP automatically calculate absolute paths and web-root folder including ports used.

Replace the above lines with the following code:

// === MPG Set base path ======================================================
$path_array = explode("www", dirname( __FILE__ ));  // Split path at www
$base           = "$path_array[0]";            // absolute path to ..UniServer/
// ================================================== MPG End Set base path ===

// === MPG Get MYSQL port =====================================================
// Use port from configuration file - because user can change this file 
$file_conf  = $base.'usr\\local\\mysql\\my.ini'; // Config file 

if ($filearray=file($file_conf)) {              // read file into array
 foreach ($filearray as $txt) {                 // scan array for port
  if(preg_match("/^\s*port\s*=\s*(\d+)/", $txt,$match)){ // check save matches 
   $mysql_port =  $match[1];                    // match found save port number 
   break;                                       // give up nothing else to do
  }
 }
}
else {                                      // failed to read file
 echo "Cannot read the file";
}
// ===================================================== END Get MySQL Port ===

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = "localhost:$mysql_port";
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = 'root';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

$root   = 'http://'.getenv("HTTP_HOST").'/moodle';         // Local testing
//$root = 'http://'.GetHostByName($REMOTE_ADDR).'/moodle'; // moving from event to event


$CFG->wwwroot   = $root;
$CFG->dirroot   = $base.'www\moodle';
$CFG->dataroot  = $base.'moodledata';
$CFG->admin     = 'admin';

The above change makes Moodle completely portable.

Top

Tip UniServer on a laptop

I lifted the following tip from gdunc blog, it looks very useful, hence I integrated this into the above:

For those users who use UniServer on a laptop and move from event to event. To allow external users to view your moodle make the following changes:

Change:

$root   = 'http://'.getenv("HTTP_HOST").'/moodle';         // Local testing
//$root = 'http://'.GetHostByName($REMOTE_ADDR).'/moodle'; // moving from event to event

To:

//$root   = 'http://'.getenv("HTTP_HOST").'/moodle';         // Local testing
$root = 'http://'.GetHostByName($REMOTE_ADDR).'/moodle'; // moving from event to event

This switches from localhost to your domain.

In addition to allow external access you need to put your servers on-line as follows:

Edit file: UniServer\www\.htaccess

Change these lines:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

To:

#Order Deny,Allow
#Deny from all
#Allow from 127.0.0.1

Top

Move Servers

One of Uniform Server’s unique features is the capability to run more than one complete server on the same PC. When running a server from a USB memory stick you can use this to great advantage and prevent server clashes. You will have noticed UniTray’s icon displays one (meaning standard ports). Moving UniServer increments this digit and so on for each server move. In reality it’s not just a port change but a complete server update, running server status displays the server characteristics.

Move Servers:

  1. Assumes a new extracted server (see note 1)
  2. Stop all running Uniform Servers
  3. Start UniTray, in folder UniServer double click on Start.exe tray icon created.
  4. Move servers, Left click tray icon > Advanced > click Move Servers multi-server operation.
  5. In the pop-up window at all prompts press enter to accept defaults.
  6. The tray icon will display 2, if you already use a server with this number repeat steps 4 and 5 each server must have a unique number.


  • After moving the servers you can now install Moodle as explained above.
  • However before proceeding you need to use the new server ports for installation.
  • To find these: Left click tray icon > Server Status


I moved the servers to icon 3 hence Apache port = 82 and MySQL port = 3308

To start Moodle installation: type http://localhost:82/moodle/install.php into your browser

Database Configuration step 4) Host Server: name becomes: localhost:3308

After installation page access requires the addition of a port number as shown

  • Site address: http://localhost:82/moodle/

Note 1:

If you have already installed Moodle on UniServer V5-Nano and want to move the servers it is possible.

  1. Follow steps 2-6 as above
  2. Edit file UniServer\www\moodle\config.php
  3. Assumes you have made the changes as explained in Hard Coded path
  4. Now locate line (6)
    Change line: $CFG->dbhost = 'localhost';
    To: $CFG->dbhost = 'localhost:3308';
  5. Save file.

Use the port number that matches your server, start the servers. Pages are accessible as mentioned above just remember to use the port number that matches your server.


Top

Cron

Moodle has a cron.php script that needs to be periodically run. It takes care of various routine tasks for example unsubscribing inactive members and sending out email messages.

Top

Manualy Run Cron

To keep Moodle happy you need to periodically run the cron.php script.

For a personal implementation of Moodle you can run cron.php occasionally by typing the following into your browser address bar:

http://localhost/moodle/admin/cron.php

Top

Automatically Run Cron

Manually running Cron can become tedious an alternative solution is to use UniServer 5.0-Nano's built in portable-cron.

Top

Enable portable Cron

Edit file: UniServer\unicon\main\run_cron.php

Uncomment this line as shown:

$dummy = file("http://localhost/moodle/admin/cron.php"); // Uncomment to enable 

Change the timer to suit application

sleep(15);  // Set required delay (seconds)

Top

Run portable Cron

Manually run cron from UniTray

  • Start: Left click tray icon > Advanced > click Start Portable Cron
  • Stop: Left click tray icon > Advanced > click Stop Portable Cron

Top

Automatically start and stop with servers

Edit file: UniServer\unicon\tray_menu\UniTray1.ini

Locate these lines under [Menu.Left] Menu section (for convenience lines have been split):

Type: item; Caption: "Start UniServer (Apache MySQL)";
 Action: shellexecute; FileName: "%PHP%\php.exe";
 Parameters: " -n %ServerConMain%\start_servers.php 7";ShowCmd: hidden; Glyph: 9

Type: item; Caption: "Stop  UniServer (Apache MySQL)";
 Action: shellexecute; FileName: "%PHP%\php.exe";
 Parameters: " -n %ServerConMain%\stop_servers.php 7";ShowCmd: hidden; Glyph: 11

  • Replace start_servers.php 7 with start_servers.php 23
  • Replace stop_servers.php 7 with start_servers.php 23

Note: Values are binary coded

 Note: Binary 1+2+4+16 = 23  
 1  - Run Apache server 
 2  - Run MySQL  server
 4  - Start Index page
 16 - Run cron

Top

Plugin

The above instructions are generic allowing you to install the latest version of Moodle.

If you prefer a click and go solution go to SourceForge

  • Under Plugins
  • Navigate to sub-folder Uniform Server 5-Nano Plugins
  • Download file V55_Moodle_l_9_7.exe

Save this to folder UniServer, to install double click on file. Moodle is pre-configured and ready to go. Check out the read me file for latest information.

Note: This plugin is intended to quickly get Moodle up and running allowing you to explore the software. If you intend running a production server delete the folders installed and perform a manual install this allows you to tailor Moodle and include any missing modules.

Top

MySQL Security

The above installation guide and associated downloadable plugin are intended to get the application up and running purely for testing.

If you are intending to put the application on line make sure to read any security advice provided with the application and check providers web site.

More impotently the above installation is an extreme security risk if put online as is. Its imperative you secure the MySQL server before putting your servers online.

Please read the following page MySQL Security and restrict privileges to any user that has connection access to your server.

Top

Summary

Although there are a large number of steps Moodle is easy to install on Uniform Server.

Real reason for installing Moodle was to test its compatibility with PHP 5.3.0 and UniServer 5.0-Nano. It takes a lot to impress me; Moodle’s installation ran flawlessly very impressive and a credit to there design team.

Top