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

To ensure that MySQL and httpd come upon 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

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 lmsdb

2. make a database user. The name can be anything you like. I used lmsdbuser.

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 lmsdb;
grant all privileges on lmsdb.* to lmsdbuser@localhost identified by '<put a pw here>';
quit

TEST the above by doing

mysql -u lmsdbuser -p
<password>

If you get connected OK then you can go on and quit.

Create lmsdata folder

mkdir /var/www/lmsdata

The default root folder for apache is /var/www/html and so lmsdata is not accessible from the web.
Next, give the apache user all the access rights to lmsdata. This is better than chmod 777 which some users seem to do.

chown apache:apache /var/www/lmsdata

Fetch lms

cd /var/www/html
git clone git://git.paradisolms.net/lms.git

This should put all of the lms in a directory called lms 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 lms 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/lms

To give apache ownership do

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