Amazon EC2 Cloud Services Installation
Note: You are currently viewing documentation for Moodle 3.2. Up-to-date documentation for the latest stable version of Moodle is probably available here: Amazon EC2 Cloud Services Installation.
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.
- 1 Install all the requirements
- 2 To ensure that mysql and httpd come up on boot.
- 3 To ensure that utf8 is used by mysql
- 4 In order to make sure php is included when httpd comes up
- 5 Create the database, database user and access rights
- 6 Create moodledata folder
- 7 Fetch moodle
- 8 Do the install
- 9 Other Resources
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 zip.so
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
[mysqld] default-character-set=utf8 default-collation=utf8_unicode_ci character-set-server=utf8 collation-server=utf8_unicode_ci datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # 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 [client] default-character-set=utf8
Check that mysql restarts with
service mysqld restart
NB edit. Later with FC16 I found that I needed to make my.cnf 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
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
At the time of writing 26-01-2012) (php-common should provide zip.so but it doesn't so I have put a copy here (http://moodle.org/mod/forum/discuss.php?d=194589)) Attached to a forum post. Perhaps a wiki buff could fix that better.
Once you have got zip.so, 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>'; quit
TEST 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
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.
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!
For another method of using Amazon EC2 for Moodle hosting you can utilize the free image created by Bitnami.org: http://bitnami.org/stack/moodle which makes creating a Moodle server on Amazon a snap (no command line necessary)