Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Install Guide for Installing Amazon EC2.

Install Guide for Installing Amazon EC2

From MoodleDocs
Revision as of 06:32, 15 December 2010 by Jamie Pratt (talk | contribs) (first draft - not finished)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

An ec2 instance is a virtual web server that can be rented out by the hour from Amazon. Prices vary depending on the power of the instance you rent out.

I recommend the following book for background reading on Amazon EC2 "Host Your Web Site in the Cloud: Amazon Web Services Made Easy by Jeff Barr Copyright ©2010 Amazon Web Services" This is the official Amazon book on their web services and tells you how to set up a web server on an ec2 instance.

The instructions below are one way in which to set up Moodle on an EC2 instance.

Rent a 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.

Connect to your ec2 instance with putty or another ssh client

Through the The Amazon Web Service Console you can set up an ssh key and attach it to the ec2 instance you have running.

Your username for an ec2 instance using the Linux AMI will be ec2-user and no password will be required if you have the private key set up correctly.

Accessing ec2 instance using putty ssh client

In order for this key to work with putty on Windows you need to import it using puttygen and then save the private key in a safe location possibly with a pass phrase (local password) to protect it. You can then associate the key file with the ssh connection in putty by opening settings in Connection/SSH/Auth and browsing for the correct 'Private Key for Authentication'

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 httpd mysql mysql-server php php-cli php-gd php-intl php-mbstring php-mysql php-pdo php-soap php-xml php-xmlrpc php-pspell

You can list all your installed packages (including dependencies) with this command :

sudo yum list installed

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

Edit httpd.conf

If you need to edit httpd.conf it is in /etc/httpd/conf

But by default the directory /var/www/html/ is the root web directory and you can install Moodle in there.

If you do edit httpd.conf then you must restart apache using this command for the changes to take effect :

sudo /sbin/service httpd restart

Set up MYSQL

mysqladmin -u root password 'new-password'

Make additional security-related changes to mysql.

mysql -u root -p
mysql> DROP DATABASE test;                            [removes the test database]
mysql> DELETE FROM mysql.user WHERE user = ;        [Removes anonymous access]
mysql> FLUSH PRIVILEGES;

Install Moodle

Now you need to :

  • create a db user
  • create a