Installation Guide for Installing on Amazon EC2
Note: You are currently viewing documentation for Moodle 2.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Installation Guide for Installing on Amazon EC2.
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.
- 1 Rent an ec2 instance
- 2 Connect to your ec2 instance with putty or another ssh client
- 3 Setting up a web server on Amazon Linux AMI
- 4 Set up MYSQL
- 5 Install Moodle
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 may want to map a domain name to point to your elastic IP address. You will need a dns provider to do this. Amazon does not provide this service at the time of writing.
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
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
sudo mysqladmin -u root password 'new-password'
Make additional security-related changes to mysql. This can be done very easily with the command "mysql_secure_installation" and answering conservatively.
sudo 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;
Now you need to :
- Install the version of Moodle required
- Create Moodle site database
- Set up cron using crontab command
Install Moodle by going to http://youelasticipaddress/roottoyourmoodleserver/ (if you have set up a domain name to point to your elasticip address then you should use that of course)
Copy the config.php that the installer creates and then go to the root of your moodleserver and do :
sudo vi config.php
Then type i to put vi in insert mode and on putty you can use the right mouse key to paste the contents of the clipboard, then delete the former contents.
Then go again to the root of your Moodle installation http://youelasticipaddress/roottoyourmoodleserver/ and complete the automatic installation of your Moodle db.