Configure the Amazon EC2 Instance

aws_technical_certificate

aws_techIn 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 Getting Started with AWS 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

Add a Comment

Your email address will not be published. Required fields are marked *