This is a review of https://www.youtube.com/watch?feature=player_embedded&v=pZFSSVVdqmw
From making account to installing Ubuntu(RHEL) on EC2
Make account with credit card number. But with choosing Micro instance, you can use EC2 freely.
In the step 'instance details', check Prevention against accidental termination, for functionality of 'restart instance'.
Key pair is for using SSH. The file should be accessed privately(make it with the command 'chmod 600 the_file.pem', and store it ~/.ssh)
Security group is a firewall(open 80, 8080(for Tomcat), 22(for SSH), 3306(mysql)).
With the command 'ssh -i the_file.pem ubuntu@the_new_instance_upper_domain.amazonaws.com', login the new Ubuntu instance(in case of RHEL, user id is 'root', not 'ubuntu').
To make shortcut command of ssh ~, move the_file.pem in ~/.ssh and create 'config' file at there(~/.ssh). The config file is like this.
Host ec2
Hostname some_upper_domain.compute.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/the_file.pem
Installing Apache, MySql, PHP
apt-get install apache2 php5 libapache2-mod-php5 mysql-server php5-mysql : install apache, php, mysql
libapache2-mod-php5 : some module for link apache and php.
php5-mysql : connect php and mysql.
service apache2 restart : restart apache.
mysql_secure_installation : setting mysql securities.
after right above, you can see hello world page(the message starts with 'It works!') in the browser with navigating the instance URL.
With Apache
apache stores all file in /var/www.
cat /var/log/apache2/error.log : to see apache log.
apt-get remove apache2 : remove apache
When I tried to install the latest version of java sdk with 'wget' command of RHEL, I found that Oracle blocked it with an agreement step. So it was impossible download it directly.
The solution what I found was a turnaround command which make it successful. The command is like this.
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz"
and the below link is an explanation of installing JDK and tomcat.
http://davidghedini.blogspot.kr/2011/02/install-tomcat-7-on-centos-rhel.html
The reason why I followed this is RHEL on EC2 doesn't support command 'yum install tomcat7' but 'yum install tomcat6' has worked.
With Tomcat for JSP
apt-get install tomcat7 : install tomcat and its dependencies.
Make sure that Tomcat's default port is 8080.
Tomcat is in /etc/init.d.
apt-get install tomcat7-admin : install tomcat7 admin.
To get into Tomcat manager UI, change /etc/tomcat7/tomcat-users.xml like this.
<tomcat-users>
<user username="some_admin_name" password="some_password" roles="maanger-gui, admin-gui" />
<!-- add the above line -->
Some unix/unix-like command tips in the middle of the review
df -h : display free disk space. '-h' means 'human readable by using unit suffixes'.
mysql -u root -p : connect mysql with root account. Password(-p) prompt will be followed. But with -u?
mysql command stream - create database, create user, create table, grant privileges on some user, etc.
CREATE DATABASE cs2212
USE cs2212;
CREATE TABLE comments (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
body TEXT NOT NULL,
PRIMARY KEY (id)
);
CREATE USER '2212dbuser'@'localhost IDENTIFIED BY 'cs221241!f3!';
GRANT ALL PRIVILEGES ON cs2212.* TO '2212dbuser'@'localhost';
FLUSH PRIVILEGES;
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 : redirect 80 port request to 8080.
iptables-save : reboot the iptable