Amazon EC2 MoodleServer
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
[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
cd /var/www/html git clone git://git.moodle.org/moodle.git
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):
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
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.
mysql -u root -p
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.
create database moodledb;
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
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:
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.
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)
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”
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.