Note: You are currently viewing documentation for Moodle 3.8. Up-to-date documentation for the latest stable version of Moodle may be available here: Amazon EC2 Cloud Services Installation.

Amazon EC2 Cloud Services Installation

From MoodleDocs

This is essentially a linux box in the cloud but at the time of writing I did not like to add it to the Linux category, it seems more general than that somehow. If this install lacks detail or doesn't work then see comments attached to this page. I start this off with some assumptions and then go though a full install using the cli. The assumptions are that you have an Amazon 32 bit EC2 Linux server setup and you have ssh & http access to it.

Install all the requirements

From the cli as root or sudo

yum install httpd
yum install mysql-server 
yum install git
yum install php
yum install php-gd 
yum install php-pear
yum install php-mbstring
yum install memcached 
yum install php-mcrypt 
yum install php-xmlrpc 
yum install php-soap 
yum install php-intl 
yum install php-zip 
yum install php-zts
yum install php-xml

Or save some typing and copy and paste this into the terminal. It will install everything one should need for a Moodle installation:

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

To ensure that mysql and httpd come up on boot.

chkconfig mysqld on 
chkconfig httpd on

To ensure that utf8 is used by mysql

edit /etc/my.cnf to read as follows (I have found that the precise lines required seem to vary as time goes on) Back up my.cnf first with

cp /etc/my.cnf /etc/mycnf.original

Then edit to read

# Disabling symbolic-links is recommended to prevent assorted security risks

Check that mysql restarts with

service mysqld restart

NB edit. Later with FC16 I found that I needed to make my.cnf read

# 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
# Disabling symbolic-links is recommended to prevent assorted security risks

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/
</IfModule> <IfModule worker.c>
LoadModule php5_module modules/
AddHandler php5-script .php AddType text/html .php
DirectoryIndex index.php

At the time of writing 26-01-2012) (php-common should provide but it doesn't so I have put a copy here ( Attached to a forum post. Perhaps a wiki buff could fix that better.

Once you have got, put it in /usr/lib/php/modules

Also you need to add

to your php.ini (in /etc)

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
<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>';

TEST the above by doing

mysql -u moodledbuser -p

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

Fetch moodle

cd /var/www/html
git clone 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.

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

Do the install

Visit http://<your amazon host>/moodle

Well, it worked for me!

Other Resources

For another method of using Amazon EC2 for Moodle hosting you can utilize the free image created by which makes creating a Moodle server on Amazon a snap (no command line necessary)