AmazonEC2でのインストール方法

提供:MoodleDocs
2012年6月2日 (土) 05:59時点におけるToshihiro KITA (トーク | 投稿記録)による版
移動先:案内検索

EC2インスタンスは、アマゾンから時間単位で借りることができる仮想ウェブサーバです。 レンタル料は、契約するインスタンスの性能によって変わります。

Amazon Web Services(AWS) でウェブサーバをセットアップする方法については、数ある書籍やウェブでの記事を参考にしてください。

下記の説明は、EC2インスタンス上でMoodleをセットアップする方法の一例です。

EC2インスタンスのレンタル契約をする

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.

Elastic IP アドレスを関連づけてファイヤーウォール上の必要なポートを開ける

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.

EC2インスタンスに putty 等の ssh クライアントで接続する

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.

putty ssh クライアントでのEC2インスタンスへのアクセス

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'

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

サービスを開始し、再起動時にも自動的に起動するように設定する

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

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

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;

Moodleのインストール

Now you need to :

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.