Você está na página 1de 10

Amazon Web Services EC2

Getting Started Guide


Table of Contents
Introduction.................................................................................................................................................3

Connecting to your EC2 instance.................................................................................................................3

Setting up User Accounts.............................................................................................................................4

Tomcat.........................................................................................................................................................4

Installation...............................................................................................................................................4

Configuration...........................................................................................................................................5

Misc.........................................................................................................................................................6

Apache.........................................................................................................................................................7

Installation...............................................................................................................................................7

Misc.........................................................................................................................................................7

MySQL.........................................................................................................................................................7

Installation...............................................................................................................................................7

Configuration...........................................................................................................................................8

PHPMyAdmin..............................................................................................................................................9

Installation...............................................................................................................................................9

Troubleshooting and Helpful Hints............................................................................................................10

2
Introduction
Amazon Web Services (AWS) provides organizations with a flexible solution to the problem of deploying
services on the web. All of this is done within the cloud which serves as the primary delivery method
to end users. The cloud uses Amazons Elastic Compute Cloud (Amazon EC2) as the web service. This
web service allows administrators to quickly deploy EC2 instances with minimal or little configuration.
These EC2 instances vary in nature but most are Linux derivatives. In reality, these are just virtual
machines accessible from the Internet when configured through the Amazon EC2 web service.

NJIT has provided you with an EC2 instance, in which you must use for your project. This EC2 instance is
considered to be a base install of a Linux derivative which you must configure appropriately to integrate
with AWS. This guide is intended to get you started in preparing the architecture for development.

Connecting to your EC2 instance


By default, your EC2 instance will be accessible by SSH. NJITs UCS will have provided you with a private
key (typically located in your AFS home directory) to connect to your EC2 instance. This will give you
direct root access to your instance. It is recommended that you do not attempt to change this as this is
the most secure way of accessing your EC2 instance.

## ssh
ssh -i-i rsa.pvt.key
rsa.pvt.key root@hostname
root@hostname

3
Setting up User Accounts
To setup remote access shell accounts for your fellow classmates, youll need to create an account for
them and setup a password. Do the following:

## useradd
useradd <username>
<username>
## passwd
passwd <username>
<username>

Note: It is very important that you create a non-dictionary password. Because this box it will be publicly
available on the Internet, it will be susceptible to brute-force attacks. By having a password for any of
your users, you are at risk of compromise and loss of all of progress made in your in project.

After you have successfully created your users, theyll be able to connect directly to the EC2 instance via
SSH.

Tomcat
The Tomcat application server allows execution of Java servlets and JavaServer Pages (JSPs). In the
preceding directions, Tomcat version 5 was used. Tomcat version 6 should follow a similar installation
and configuration.

Installation
To begin the installation process, well use the YUM installer:

## yum
yum install
install tomcat5-ad*
tomcat5-ad*
## yum
yum install
install tomcat5-web*
tomcat5-web*

After it has successfully installed, start the service and open your browser to http://hostname:8080
(NOTE: you must have requested from NJIT UCS prior to open port 8080 on the EC2 instance, changing
the port to 80 will not work due to security restrictions.)

## /etc/init.d/tomcat5
/etc/init.d/tomcat5 start
start

4
Configuration
To configure a user to access Tomcat youll need to modify the tomcat-users.xml file located in
/etc/tomcat5.

## nano
nano /etc/tomcat5/tomcat-users.xml
/etc/tomcat5/tomcat-users.xml

<?xml
<?xml version='1.0'
version='1.0' encoding='utf-8'?>
encoding='utf-8'?>
<tomcat-users>
<tomcat-users>
<role
<role rolename="tomcat"/>
rolename="tomcat"/>
<role
<role rolename="role1"/>
rolename="role1"/>
<role
<role rolename="manager"/>
rolename="manager"/>
<role rolename="admin"/>
<role rolename="admin"/>
<user
<user username="tomcat"
username="tomcat" password="tomcat"
password="tomcat" roles="tomcat"/>
roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user
<user username="role1"
username="role1" password="tomcat"
password="tomcat" roles="role1"/>
roles="role1"/>
<user
<user username="adminuser"
username="adminuser" password="securepw"
password="securepw" roles="admin,manager"/>
roles="admin,manager"/>
</tomcat-users>
</tomcat-users>
5
In this file, you can create users and assign roles. The admin and manager roles are built-in that allow
access to the manager web interface and administration interface. By default, the user tomcat does
not have full access to the administrative interface. Any modifications to this file will require that you
restart the Tomcat5 service.

Misc
Server code for your tomcat web apps is located in /var/lib/tomcat5/webapps. It is
recommended that you put most your code for Tomcat in this directory.

All configuration files are located in /etc/tomcat5.

6
Apache
Apache is a fully scalable HTTP web server which allows the serving of web pages.

Installation
To begin the installation process, well use the YUM installer:

## yum
yum install
install apache
apache

After it has successfully installed, start the service and open your browser to http://hostname (NOTE:
you must have requested from NJIT UCS prior to open port 80 on the EC2 instance.)

## /etc/init.d/httpd
/etc/init.d/httpd start
start

Misc

By default, all web content is stored in /var/www/html.

MySQL
MySQL is a relational database management system which allows for fairly robust database architectures
with muti-user level access.

Installation
To begin the installation process, well use the YUM installer:

## yum
yum install
install mysql-server
mysql-server

After it has successfully installed, start the service.

## /etc/init.d/mysqld
/etc/init.d/mysqld start
start

7
Configuration
In order to begin creating and using the database youll need to setup root with administrative access.

## /usr/bin/mysqladmin
/usr/bin/mysqladmin -u
-u root
root password
password <securepassword>
<securepassword>

Log into mysql with the root user:

## mysql
mysql -u
-u root
root -p
-p
Enter password:
Enter password:
Welcome
Welcome to to the
the MySQL
MySQL monitor.
monitor. Commands
Commands end
end with
with ;; or
or \g.
\g.
Your
Your MySQL
MySQL connection
connection id
id isis 33
Server
Server version:
version: 5.0.45
5.0.45 Source
Source distribution
distribution

Type
Type 'help;'
'help;' or
or '\h'
'\h' for
for help.
help. Type
Type '\c'
'\c' to
to clear
clear the
the buffer.
buffer.

mysql>
mysql>

To create a database named cs633, issue the following command:

mysql>
mysql> create
create database
database cs633;
cs633;
Query
Query OK, 1 row affected (0.00
OK, 1 row affected (0.00 sec)
sec)

mysql>
mysql>

To grant special privileges to a teammate who will be responsible for administrating the database, issue
the following command:

mysql>
mysql> grant
grant all
all privileges
privileges on
on cs633.*
cs633.* to
to <teammatesusername>@"localhost"
<teammatesusername>@"localhost"
identified by '<password>';
identified by '<password>';
Query
Query OK,
OK, 00 rows
rows affected
affected (0.00
(0.00 sec)
sec)

Flush privileges to write the privileges:

mysql>
mysql> flush
flush privileges;
privileges;
Query
Query OK,
OK, 00 rows
rows affected
affected (0.00
(0.00 sec)
sec)

8
PHPMyAdmin
If you prefer not to create or manage your database via the command line, you can use a graphical
interface such as PHPMyAdmin. Prior to installation of PHPMyAdmin it is recommended that you have
installed and configured Apache. Refer to the Installing Apache section if you need assistance.

Installation
To begin the installation process, well use the YUM installer:

## yum
yum install
install phpMyAdmin.noarch
phpMyAdmin.noarch

Now point your browser to http://hostname/phpmyadmin and login with the root password you setup
for the database administrator. Additionally, any user which you configured previously, can access this
web interface.

Note: if you receive a message such as Forbidden or Access Denied, you will need to modify the
PHPMyAdmin configuration file located at /etc/httpd/conf.d/phpMyAdmin.conf to allow access. To
ensure security, it is recommended that you allow PHPMyadmin to be accessible only by a certain IP or
IP range. Also, ensure that deny from all is uncommented.

## nano
nano /etc/httpd/conf.d/phpMyAdmin.conf
/etc/httpd/conf.d/phpMyAdmin.conf

<---phpMyAdmin
<---phpMyAdmin snippit
snippit cut
cut --->
--->
<Directory /usr/share/phpMyAdmin/>
<Directory /usr/share/phpMyAdmin/>
order
order deny,allow
deny,allow
deny
deny from
from all
all
allow
allow from x.x.x.x
from x.x.x.x
</Directory>
</Directory>

9
Troubleshooting and Helpful Hints
The YUM installer can run into issues when it cant download a specific package and will fail. To
fix this issue the following command: yum clean metadata. After issuing this command you
should be able to install the package you previously had trouble with.

The easiest method to transfer files to your EC2 instance is to use SFTP or SCP. A client such as
WinSCP(winscp.net) or FileZilla(filezilla-project.org) can assist you with this. Simply supply your
SSH credentials and the hostname to the client. You will then be able to transfer files.

If you are looking for a package in the YUM repository try issuing the command: yum search
<packagename>.

To see a listing of all packages installed on the current system, issue the following command:
yum list.

To download files directly to the EC2 from the command line, use wget.

To get a listing of daemons or services currently running, issue the command: ps e.

To kill a daemon or service, make note of the PID # and kill it by doing the following: kill <PID#>.

Just as you can start services you can also shut them down or restart them. To shutdown a
service such as the Apache web server you can issue the following command: /etc/init.d/apache
shutdown. To restart it, issue the following command: /etc/init.d/apache restart.

10

Você também pode gostar