Getting Started Guide
AWS Computing Basics for Linux
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Configure the Amazon EC2 Instance

In this topic, we will configure the running instance. You will do the following tasks:

  • Set permissions on the settings file

  • Install MySQL Server.

  • Start the web server and MySQL.

  • Configure a database.

  • Configure the application.

To simplify this tutorial, we are creating a database that will run locally on one Amazon EC2 instance. You will configure the Drupal application to use this Amazon EC2 instance for your database; all other Amazon EC2 instances will connect to this instance to access the database.

If you are going to use more than one Amazon EC2 instance, you will usually set up your database on a different server from the one that is running your application. That way, the information is stored in one location, and all instances have access to the same data instead of a local running database that may be out of sync.

Creating a separate database is beyond the scope of this document. For more information about setting up Amazon RDS for your web application, go to Step 8: Add Amazon RDS inside the Getting Started Guide Web Application Hosting for Linux.

To set permissions on the settings file

  • On your Amazon EC2 instance, at a command prompt, use the following command to set permissions:

    sudo chmod 666 /var/www/html/sites/default/settings.php

To install a MySQL Server

  • On your Amazon EC2 instance, at a command prompt, use the following command to install MySQL Server:

    sudo yum install mysql-server

    When you are prompted, type 'y'.

To start the web server and MySQL

  1. On your Amazon EC2 instance, at a command prompt, start the web server, and then configure it to start up automatically on reboot:

    sudo chkconfig httpd on
    sudo service httpd start

    You'll see a response like the following.

    Starting httpd [OK]
  2. Start mysql, and configure it to start up automatically on reboot.

    sudo chkconfig mysqld on
    sudo service mysqld start

    You'll see a response like the following.

    Starting mysqld [OK]

To configure a database

  1. On your Amazon EC2 instance, update the password for the 'root' user. In this example, you'll use the password 'root'.

    mysqladmin -u root password root
  2. Create a database. In this example, you'll use the database name 'mydb'.

    mysqladmin -u root -p create mydb

    When you are prompted for a password, type 'root'.

  3. Sign in and set the access database rights.

    mysql -u root -p

    When you are prompted for a password, type 'root'.

  4. At the MySQL prompt, set the permissions by using the following command. Replace <your public EC2 DNS address> with the public DNS address of the Amazon EC2 instance, which you recorded in Step 4: Launch an Instance.

    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON mydb.* TO 'awsuser'@'<your public EC2 DNS address>' IDENTIFIED BY 'mypassword';

    If successful, MySQL will reply with the following:

    Query OK, 0 rows affected
  5. At the MySQL prompt, set the permissions by using the following command.

    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON mydb.* TO 'awsuser'@'%' IDENTIFIED BY 'mypassword';

    If successful, MySQL will reply with the following:

    Query OK, 0 rows affected
  6. To activate the new permissions, enter the following command:

    FLUSH PRIVILEGES;

    If successful, MySQL will reply with the following:

    Query OK, 0 rows affected
  7. Exit the MySQL prompt by typing the following:

    exit

    The server responds with the following:

    Bye

To configure the application

  1. Open your web browser. In the Address box, type the public DNS address of the Amazon EC2 instance, which you recorded in Step 4: Launch an Instance. The Choose profile page appears in the Drupal installation wizard.

  2. On the Choose profile page, click Standard, and then click Save and continue.

  3. On the Choose language page, click English, and then click Save and continue. The Set up database page appears.

  4. On the Set up database page, enter the following information.

    1. Under Database type, click MySQL, MariaDB, or equivalent.

    2. In the Database name box, type the name of your database. In this example, you'll use mydb.

    3. In the Database username box, type the user name for your database. In this example, you'll use awsuser.

    4. In the Database password box, type the password for your database. In this example, you'll use mypassword.

    5. Click Advanced Options.

    6. In the Database host box, type the public DNS address of your Amazon EC2 instance, which you recorded in Step 4: Launch an Instance.

    7. Click Save and continue.

  5. On the Configure site page, enter the following information.

    1. In the Site name box, type a name for your site.

    2. In the Site e-mail address box, type your email address.

    3. In the Username box, type a user name.

    4. In the Password box, type a password that corresponds to the user name.

    5. In the Confirm password box, retype the password.

    6. Click Save and continue.

    The installation is complete.

  6. Click Visit your new site.

  7. To add a new article to your site, click Add new content.

Congratulations! You have successfully deployed your web application with Amazon Web Services. In the future, if you decide that you want to launch more instances, you won’t want to customize each one. Let's create a custom AMI that incorporates all the configuration changes we’ve made.