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.

Amazon EC2 Cloud Services Installation: Difference between revisions

From MoodleDocs
(ja link)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is essentially a linux box in the cloud but at the time of writing I did not like to add it to that category. 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. Assumptions you have an Amazon 32 bit EC2 server setup and you have ssh & http access to it.
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 =
= Install all the requirements =
Line 11: Line 12:
  yum install php-pear
  yum install php-pear
  yum install php-mbstring
  yum install php-mbstring
yum install php-mcrypt
yum install php-mbstring
  yum install memcached  
  yum install memcached  
  yum install php-mcrypt  
  yum install php-mcrypt  
yum install php-zts
  yum install php-xmlrpc  
  yum install php-xmlrpc  
  yum install php-soap  
  yum install php-soap  
Line 22: Line 20:
  yum install php-zts
  yum install php-zts
  yum install php-xml
  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. =
= To ensure that mysql and httpd come up on boot. =
Line 31: Line 33:
= To ensure that utf8 is used by mysql =  
= To ensure that utf8 is used by mysql =  


edit /etc/my.cnf to read as follows
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]
  [mysqld]
Line 48: Line 54:
  [client]
  [client]
  default-character-set=utf8
  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 =
= In order to make sure php is included when httpd comes up =
Line 62: Line 89:




At the time of writing 26-01-2012) (php-common should provide zip.zo but it doesn't so I have put a copy here {http://moodle.org/mod/forum/discuss.php?d=194589]
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.
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
Once you have got zip.so, put it in /usr/lib/php/modules
Line 113: Line 140:


The default root folder for apache is /var/www/html and so moodledata is not accessible from the web.
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
  chown apache:apache /var/www/moodledata


= Fetch and do permissions on moodle =
= Fetch moodle =


cd /var/www/html
cd /var/www/html
git clone git://git.moodle.org/moodle.git


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.
 
This should put all of moodle in a file called moodle in the correct folder /var/www/html


There are more sophisticated git commands, see git docs in moodle docs for more info.
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


chown -R apache:apache ./moodle
To give apache ownership do


chown -R apache:apache /var/www/html/moodle


= Do the install =
= Do the install =
Line 134: Line 164:


Well, it worked for me!
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 Bitnami.org: http://bitnami.org/stack/moodle which makes creating a Moodle server on Amazon a snap (no command line necessary)
[[ja:Amazon EC2クラウドサービスインストレーション]]

Latest revision as of 15:48, 2 January 2015

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

extension=zip.so

to your php.ini (in /etc)

Create the database, database user and access rights

run

mysql_secure_installation

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.

run

 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

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://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!

Other Resources

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)