K12LTSP-Moodle Howto
From K12LTSP Wiki
K12LTSP - Moodle Install
This is a step by step guide to installing Moodle on a K12LTSP based Linux server. You must be root to perform the following steps.
1. Install K12LTSP with the default options.
2. You can select to install a web server httpd during the install or afterwards. If you didn't install httpd or you're not sure, just type,
rpm -q httpd
to see if it is installed. If it is, you'll get a result like this:
httpd-2.2.2-1.0
If you don't have httpd installed, type
yum install httpd
and answer yes when your server downloads the httpd rpm and any required dependencies.
3. Next, you'll want to install mysql and the mysql-server packages along with some of the packages Moodle will use,
yum install mysql mysql-server php php-gd php-pear php-mysql gmp mimetex php-mbstring perl-GD
Say yes to any dependencies and install the packages.
4. Now check and see if your web server [httpd] and mysql server are running,
service httpd status
result >> httpd is stopped
service mysqld status
result >> mysqld is stopped
If they are stopped, you can turn them on with
service httpd start
service mysqld start
You should set these services to start automatically when you server boots. You can turn on these services from the Service Configuration dialog.
System >> Administration >> Services
Turn on httpd and mysqld. You should also click the boxes next to these services so they will start when the server boots.
5. There are just a few web server configuration settings we'll need to check. Use an editor and open /etc/php.ini and search for these phrases and make changes to settings as reqiured ( 1on, 0off ),
magic_quotes_gpc = 1 ; (preferred but not necessary)
magic_quotes_runtime = 0 ; (necessary)
file_uploads = 1
session.auto_start = 0
session.bug_compat_warn = 0
While you're editing php.ini you might want to adjust the file upload settings. Increase or decrease as desired,
upload_max_filesize 2M
post_max_size 2M
6. Next we need to modify one line in /etc/httpd/conf/httpd.conf so that httpd will use index.php as a directory index page as well as index.html and index.htm. Open up /etc/httpd/conf/httpd.conf and search for this line and change settings as required.
DirectoryIndex index.php index.html index.htm
7. Now it's time to download the Moodle package. Head for [1] and download the "Latest Stable Branch." Save this file to your desktop then move it to /var/www/html/,
mv ~/Desktop/moodle-latest-16.tgz /var/www/html/
8. Go to the directory and extract the file,
cd /var/www/html
tar zxvf moodle-latest-16.tgz
9. Make a directory for the moodle data called moodledata, change its permissions so that it is owned by apache and accessible by apache ONLY. This directory should NOT be in your html document directory. A good place for it is one directory higher, in /var/www/
cd /var/www/
mkdir moodledata
chown apache moodledata
chmod 700 moodledata
10. Before you can run the Moodle install scripts (provided with the package) you'll need to create a database, user and password for Moodle.
The first thing we'll do to get the database ready is create a password in MySQL for the root account on your server.
To set your password, login to mysql from a terminal with this command:
mysql -u root
Then use this command to set your new password. Don't use the same password that you use for your root login account. You'll need to makeup a password here just for the mysql database root user. Don't forget the semi-colon at the end of the command.
SET PASSWORD FOR root@localhost=PASSWORD('yourdbpasswordhere');
Type exit to leave the database:
exit;
Now try logging into mysql as the root user,
mysql -u root -p
That -p will cause mysql to prompt you for your new password. Don't forget it. Now we'll make a database and a user just for Moodle.
11. Next, create the database. Once you're logged in, type these commands. Don't forget the semi-colon at the end of each line. If you mess up, you can always < ctl-c > to exit and start over again. Change the name of database, user and password as desired but keep the 'quote marks' as they are in the syntax. The first line ends with ; but the second line is longer. Don't use a " ; " until the end of the line.
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8unicodeci; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'yourpassword'; quit
12. What you just did was create a database called "moodle" and with the grant command, create a database user named "moodleuser" with a password of "yourpassword." You did change those to personalize them for your own server didn't you? ;-)
13. Tell mysql to reload the database information for your new database and user:
mysqladmin -p reload
14. We're almost there. Before we can run the Moodle install script, we'll have to tell SELinux to allow scripts and modules to connect to the network. From the System menu select:
Administration >> Security Level and Firewall
Then click on the SELinux tab and click on the little triangle next to Modify SELinux Policy and then click on HTTPD Service and finally put a check in the box next to Allow HTTPS scripts and modules to connect to the network.
If you don't do this, you'll get an error message during the Moodle web based install that says, "The Web Address does not appear to be valid."
15. Our next step is to connect to Moodle and tell it about its new database. Open a browser window and enter this address: ~http://localhost/moodle/
The first thing Moodle will do is ask you about your default language and then test your server for some of the basic settings. If you've been following this guide, you'll pass all the tests. Then you'll come to a screen where you can enter the paths to the moodle web site, moodle directory and data directory.
If you get all of that correct, then Moodle will create a config.php file for you. If it can't write to the Moodle directory, it will show you the text for the file and let you create it (config.php) and place it in the /var/www/html/moodle/ directory.moodle screenshot
16. At this point, once Moodle finds your config.php file, you have a working Moodle server. You'll just need to agree to the license and then make some configuration choices in the next few screens. There are many configuration options, many of which you can leave at their defaults. Be sure to change the "Data Directory" to the path you set earlier, "/var/www/moodle". As you make choices you'll have to click on "continue" on the bottom of each page. The Moodle install scripts are installing the database with each click. It may take some time. You'll know you're finished with this section when you get to the "Site Settings" page where you can enter the name of you Moodle site and information for your welcome page.
