| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
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
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]
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
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
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'.
Sign in and set the access database rights.
mysql -u root -p
When you are prompted for a password, type 'root'.
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
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
To activate the new permissions, enter the following command:
FLUSH PRIVILEGES;
If successful, MySQL will reply with the following:
Query OK, 0 rows affected
Exit the MySQL prompt by typing the following:
exit
The server responds with the following:
Bye
To configure the application
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.
On the Choose profile page, click Standard, and then click Save and continue.

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

On the Set up database page, enter the following information.
Under Database type, click MySQL, MariaDB, or equivalent.
In the Database name box, type the name of your database. In this
example, you'll use mydb.
In the Database username box, type the user name for your database. In this example, you'll use awsuser.
In the Database password box, type the password for your database. In this example, you'll use mypassword.

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

Click Save and continue.
On the Configure site page, enter the following information.
In the Site name box, type a name for your site.
In the Site e-mail address box, type your email address.
In the Username box, type a user name.
In the Password box, type a password that corresponds to the user name.
In the Confirm password box, retype the password.

Click Save and continue.
The installation is complete.

Click Visit your new site.

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.