fbpx

Moodle Server Setup (also Joomla via Joomdle) on Amazon EC2 and GoDaddy


Amazon EC2 MoodleServer

The first part of this is largely a composite of two wiki articles at the Moodle.org Wiki started separately by Jamie Pratt and Brian Lockwood that taken together finally explained everything I had to do in order to get Moodle working on an Amazon EC2 server:
 
 

Rent an ec2 instance

You can set up an account with Amazon Web Services and rent out a ec2 instance here The Amazon Web Service Console

I used an instance of the Amazon Linux AMI based on Elastic Block Store. Using an instance based on an Elastic Block Store gives you more options for backing up your disks later. The “Amazon Linux AMI” is based on CentOS and is a pared down version of linux with only the bare essentials included, that should be more secure. You can use the yum command to install anything extra necessary on your server.

Attach an ‘elastic ip’ and open necessary ports on firewall

Again through the The Amazon Web Service Console :

  • I created and attached an elastic ip address to the ec2 instance I had launched with the Amazon Linux AMI.
  • I opened ports 22 and 80. For my purposes I did not intend to make the server accessible through https so these were sufficient.

You then start up the SSH server (launch an Instance), which opens to a linux terminal. In the Plugins section, there is also an SFTP/SCP file transfer tool among other things, but you’ll be doing most of your work in the terminal and console now.

Setting up a web server on Amazon Linux AMI

Make sure all your currently installed packages are up to date.

   sudo yum -y update

You use yum to install all the software you need on your server. You can use the following command to install apache, mysql and php and the php extensions and all dependencies required by Moodle with this command :

sudo yum -y install aspell aspell-en aspell-fr aspell-es cvs git httpd memcached mysql mysql-server php php-cli php-gd php-intl php-mbstring php-mcrypt php-mysql php-pdo php-pear php-pecl-zip php-pspell php-soap php-xml php-xmlrpc php-zip php-zts unzip zip zip.so

Start server services and have them start up automatically on a reboot

Configure the new services to start automatically. sudo /sbin/chkconfig httpd on sudo /sbin/chkconfig mysqld on sudo /sbin/service httpd start sudo /sbin/service mysqld start

To ensure that utf8 is used by mysql

edit /etc/my.cnf to read as follows Back up my.cnf first with:

cp /etc/my.cnf /etc/mycnf.original
Then edit to read:
[mysqld]
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under different user or group, 
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character-set-server=utf8
collation-server=utf8_unicode_ci
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Check that mysql restarts with

service mysqld restart

In order to make sure php is included when httpd comes up, make sure you have a file called /etc/httpd/conf.d/php.conf whose contents are like the following:

<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule> <IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
AddHandler php5-script .php AddType text/html .php
DirectoryIndex index.php

Once you have got zip.so, put it in /usr/lib/php/modules, Also you need to add

extension=zip.so

to your php.ini (in /etc)
 

Fetch moodle

cd /var/www/html git clone git://git.moodle.org/moodle.git

This should put all of moodle in a directory called moodle in the correct folder /var/www/html. It takes a while but you get %age feedback.
 
Alternatively, download Moodle (and Joomla — and Joomdle that integrates the two, for that matter), upload the zip files using WinSCP, and unzip them using unzip. I always re-name the files first to shorter names for easier typing. Moodle unzips into a moodle folder already – you can unzip Joomla into the HTML root. This is far faster than using GIT or using WinSCP for file and folder uploading.
 

http://www.cyberciti.biz/tips/how-can-i-zipping-and-unzipping-files-under-linux.html 

You’ll need the following to convert Amazon’s private key file that you saved to your hard drive to the .ppk version WinSCP uses (See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html#putty-getting for reference):

Get all three of these if you want to integrate Moodle with a Joomla CMS:

There are more sophisticated git commands, see git docs in moodle docs for more info. Also, you may give the apache user ownership of the site, this way, when you install, the script will be able to create the config.php file. If you leave the owner as root, you will have to paste the suggested config.php into /var/www/html/moodle

To give apache ownership do:

chown -R apache:apache /var/www/html/moodle

Create the database, database user and access rights

run

mysql_secure_installation

Answer all the questions conservatively. (e.g. You will not need test databases or for root to have any other mysql access than local.) This will create a root mysql pw for you. Mysql users are nothing whatsoever to do with you unix users.

run

mysql -u root -p

<password you set above>

In mysql you need to

1. make a database. The name can be anything you like. I used moodledb

2. make a database user. The name can be anything you like. I used moodledbuser.

3. give that user rights to access the database from the localhost.

4. No db access is required by anyone from any other host than the localhost
 
Now you are in mysql and all the commands are mysql commands and could equally be run on a windows instance of mysql. Do not forget the “;” after each command.

create database moodledb;

grant all privileges on moodledb.* to moodledbuser@localhost identified by ‘<put a pw here>’;

quitTEST the above by doing

mysql -u moodledbuser -p <password>

If you get connected OK then you can go on and quit.

Create moodledata folder

mkdir /var/www/moodledata

The default root folder for apache is /var/www/html and so moodledata is not accessible from the web. Next, give the apache user all the access rights to moodledata. This is better than chmod 777 which some users seem to do.

chown apache:apache /var/www/moodledata


Install Joomla and Joomdle if you want to integrate the Joomla CMS with Moodle:

http://www.joomdle.com/wiki/Prerequisites 

http://www.joomdle.com/wiki/Installation

USING VI/VIM

 

https://www.washington.edu/computing/unix/vi.html 


Alternatives to AWS hosting

Godaddy has a built-in Joomla installer if you want to use Joomdle to combine Moodle with Joomla. Reportedly a Moodle installation with between 10 and 50 students works fine on their shared hosting, though you’d want at least VPS for more than that. They have an economy VPS for $29.99/mo and their normal VPS server goes for $39.99/mo. Their dedicated servers start between $200-$250/mo for a fair size school, and upwards after that.

The best way to install Moodle is to upload the zipped moodle file and un-archive it in GoDaddy’s File Manager. Upload the zip to the folder you want (one, perhaps, that a subdomain is pointing to) and un-archive it there, and it will place a moodle folder inside of that.
Then in the MySql control panel, create a new database that will hold Moodle’s DB. Keep the login and server address info handy as you’ll need it during the installation of Moodle.
Furthermore, in GoDaddy, you need to change the php5.ini setting for allow_url_fopen to “on” if you want to employ Joomdle:
php5ini
edit button
allow_url_fopen_off
allow_url_fopen_on
Once that is edited and saved, you need then to re-start the web processes so it will re-start PHP and read the new settings:
systemprocesses
 end web
I also encountered an issue where my PHP 5.3 was not being recognized, even though the “Programming Languages” control panel showed that to be selected. (Moodle saw 5.2.17). It turned out the culprit was in the “File Extensions” control panel – the .php extension had to be pointed to the 5.3 version manually. Then it worked just fine.

Review of using AWS/EC2 for Moodle – prognosis is not sounding good, as the I/O requirements of Moodle are a bit much for EC2 compared with other solutions (VPS or rented/owned hardware server)

Grant responded:

Hi Ian, just noticed your follow-up from a month ago.

We have stopped using Amazon for anything except backups using s3cmd to safely backup critical folders to S3. (Moodle only)

One thing I have learned about Moodle is it extremely dependent on I/O due to database reads/writes. (not ideal on AWS)

Secondly, these pay by hour cloud providers may work but really aren’t worth the headache and investment (look at Ian’s efforts thus far and mine)… If you must, I recommend getting a larger installation and simply reducing the hours of operation. Tell your students the system is offline between midnight and six, or whatever you can pull off.

Medium 30 x 24 = 720hr @ $130.00 (3.75GB Ram / 2EC 1 Core)

Medium 30 x 18 = 540hr @ $97

Large 30×24 = 720hr @ $260 (7.5GB Ram / 4EC 2 Core)

Large 30×18 = 540hr @ $195

Based on my experience the rates/performance are to high even when operating at reduced hours.

Unfortunately Moodle and AWS simply don’t match up.

Anyone with a budget under $20/month

Find a dedicated VPS if your lucky and use nginx and caching

Anyone with a budget of $20 – $50/month

Find a dedicated VPS with higher specs or entry level dedicated server.

Anyone with a budget of 50+/month find a dedicated server on special. You will be the only one using the server, meaning no one else is using resources. This is a common issue in cloud/vps environments.

Anyone with a budget of 100+/month do not rent a server, buy one!

You can typically find colocation hosting in USA data centers for 50+ and up per month. A decent spec. rented server might run $200-$300 monthly. Typically you can build and run the same spec. server for about half that cost. Which is what we do now!

Plus when you build it, you can tailor your server to your needs. I am hinting at I/O and ram.

Server Example: ($1750)

i5-2400 (4C @ 3.4Ghz) / 32GB RAM DDR3 1333 / 4 x SAMSUNG 830 128GB SSD / Adaptec RAID 6405 with 512Mb Cache (Raid 10)

Colocation Example ($711 / year)

100mbps / 10 IP / Power / Control Panel

I consider the above a budget server yet extremely powerful. I dare you to configure something on Dell’s website that comes close. In Raid10 with the adaptec raid card this server will be able to handle extreme I/O of Moodle’s read/writes requirements.

Total cost about $2500 for the first year which puts us around $200 monthly or less then the Large EC2 instance with 7.5GB of ram and 4EC. Plus we own the server and expect to keep it in production for 2-3 years. Also in the future we may turn this into a dedicated MySQL server depending on how everything plays out.

If your using Moodle, why bother with AWS?

Ian, are you still fighting with AWS and Moodle?
,

2 responses to “Moodle Server Setup (also Joomla via Joomdle) on Amazon EC2 and GoDaddy”

  1. Great work putting it all together. It may be a little too much for an inexperienced user. I would recommend to use the automated deployment for that. For example Deploy4Me installs Moodle on AWS in a few clicks. It configures database, security and Linux. No pain. It is the 21st century.

    • I agree, and your URL is one of the few I’m allowing to remain intact! 🙂

      Of course, some people like doing it all themselves so they know what is going on “beneath the hood” and can tweak it to their heart’s content, but this kind of service removes barriers from more people making use of Moodle and getting education and training offers out there.

      Terry

Leave a Reply

Your email address will not be published. Required fields are marked *

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security