Monday, 26 March 2012

Moodle 2 - Configuring the Linux Box

In this series of blogs I will be detailing my installation, setup and configuration of one of our new Moodle 2 enviroments. I will cover:
  • Configuring the Box
    • On Red Hat Linux
    • PHP configuration
    • Mysql Configuration
  • Installng Moodle 2
  • The first simple setup steps
  • Creating some users and courses
  • Some advanced setting we will use
  • Google Mail Integration
  • LDAP integration
  • Single Sign on Integration (NTLM)
  • Mods and Blocks we want.
Configuring the Box.
This first post is about configuring the box and for this I am jumping into the point where RED Hat has just been installed and it has a GUI installed (though I will use the terminal). 

http://docs.moodle.org/22/en/Installing_Moodle - Are the requirements for Moodle 2.2 and here it tells us that the version of PHP we want is 5.3.2. In a terminal window run:

$ php-v  

I had version 5.3.3 installed and so didnt need to upgrade. 

The next thing we should do is create a phpinfo file that we can use to check our php configurations. This will run on the webserver on our box so we need to check the webserver status. In a terminal window run:

$ service httpd status  

Assuming that httpd (the web server service) is stopped we need to start it: Run (as root):
$ service httpd start   
If a warning about failing to determine the servers fully qualified domain name, then edit the /etc/httpd/conf/httpd.conf file and where it wants to specify the 'serverName' then uncomment this and put in the ipaddress (or domain name) of what the new Moodle will be. 

PHP

Next create a phpInfo.php file inside the webserver directory (It will tell you where this directory is in the httpd.conf file above), but, it is usually /var/www/html. Inside there create a new file called phpInfo.php and the contents of the file want to be:


<?php
phpinfo();
?>

Then open up a browser and type: http://localhost/phpInfo.php and hopefully the extensions and php information will be displayed. It may not show the mysql information if the mysql service hasnt been started yet:

As root, in a terminal type:


$ service mysqld status
$ service mysqld start 

In the php information output from above take not of the location of your php.ini file (mine was /etc/php.ini). This is where we will be checking/changing some settings. 
At http://docs.moodle.org/22/en/PHP there is a list of the extensions that moodle 2 needs. 
In my out of the box php configuration:
(for the following yum commands you may need to do a yum-update first)


iconv -> Was Enabled (Checked by looking at the phpinfo output)
mbstring -> ran '$ yum install php-mbstring' and then added 'extension=mbstring.so' to the php.ini file. Restart httpd.

(As a side not the above command complained about package can not be found. I used '$ yum repolist all' to view all available repos. I then added server-optional repository using '$yum-config-manager --enable rhel-6-server-optional-rpms'). See https://access.redhat.com/knowledge/articles/58637).

curl -> was enabled.
openssl -> was enabled.
tokenizer->was enabled
xmlrpc -> do '$yum search xmlrpc' you should see a package called php-xmlrpc.i686. Install it using '$yum install php-xmlrpc.i686'. Add 'extension=xmlrpc.so' to the php ini file and restart the httpd service. (if you look in /etc/php.d you will see the .ini files we are installing and thus the name to have in the extensions section of the php.ini)
soap -> search for soap as above. '$yum install php-soap.i686'. Then in php.ini add extensions=soap.so
ctype -> was enabled
zip -> was enabled
gd -> was enabled
simplexml -> was enabled
spl -> was enabled
pcre -> was enabled.
dom -> was enabled.
xml ->was enabled.
intl -> '$yum install php-intl.i686' add 'extensions=intl.so' and restart the service.
json -> was enabled.

For our installation I am using a mysql database. This means that I need mysql support in PHP.

I search for mysql, installed the php-mysql.i686 rpm, added extension=mysql.so and restarted the httpd service.


Our installation will later require LDAP integration so at somepoint I need to add these extensions in. However I will leave that to when I set LDAP up.    

MYSQL

So, I now have php set up. Its now time to configure and set the mysql up.

First thing is to change the root password of mysql.

'$ mysqladmin -u root password <Your_new_password>'. 
Now we are going to set up a Moodle user for our database and create the moodle database itself.

$mysql -p 
This will ask for the password set above and then will get us into mysql.

Next we are going to create a database called moodle and a new moodle user. Within the mysql account. (so you are entering into mysql>). Type:

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; 


GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER on moodle.* TO newusername@localhost IDENTIFIED BY 'yournewpassword'; 

Where above the database is whatever you want to call the database and 'newusername' is a new user you are creating for the mysql database.

Performance and Memory

So far I have not configure the server for performance or memory optimisation. For now I am leaving these as default but I will return to this at a later date.

Conclusion

Now our  system should be set up so we can go ahead and install a new installation of Moodle 2. This is what I will be doing in step 2.


No comments:

Post a Comment