Steps on creating Amazon EC2
1.Create an Amazon EC2 account then create the keys and certificates then download them and save to your local machine.
2. set the paths as follows:
export JAVA_HOME=/home/anoop/java
export PATH=$PATH:$JAVA_HOME/bin
export EC2_HOME=/home/anoop/ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_CERT=cert-xxxxxxx.pem
export EC2_PRIVATE_KEY=pk-xxxxxx.pem
*You should have Java and ec2 tool installed.
ec2-add-keypair my-keypair
vi id_my-keypair
then copy the result of previous command and save it using wq command
chmod 600 id_my-keypair
ec2-run-instances ami-xxxx -k my-keypair
ec2-describe-instances
ec2-allocate-address
ec2-associate-address -i i-xxxx xxx.xxx.xxx.xxx
Now the ’server creation’ is complete, now log in to the server using
ssh -i id_my-keypair root@the_ip_address_you_got_from_amazon_and_assigned_to_your_instance
Then change the root password and you may change the settings on sshd_config so that you can use password authentication than key. Also its recommended to disable root login through ssh.
Now download the Java for Linux and install it by running the install script:
<!– @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } –>
./j2sdk-1_4_2_16-linux-i586.bin
ln -s j2sdk1.4.2_16/ java
vi ~/.bash_profile
Then add:
<!– @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } –>
export JAVA_HOME=/mnt/installs/java
PATH=$JAVA_HOME/bin:$PATH$HOME/bin:/sbin:/usr/sbin:/usr/local/pgsql/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin:/root/bin:/root/bin
export JAVA_HOME PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
————————–
======
Install Tomcat
======
tar xvfz jakarta-tomcat-4.1.30.tar.gz
ln -s jakarta-tomcat-4.1.30 tomcat
edit ~/.bash_profile
export JAVA_HOME=/opt/installs/java
export CATALINA_HOME=/opt/installs/tomcat
export TOMCAT_HOME=/opt/installs/tomcat
export PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:/sbin:/usr/sbin:/usr/local/pgsql/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin:/root/bin:/root/bin
export PATH
unset USERNAME
—————————
yum install openssl*
yum install readline-devel*
yum install compat-readline*
tar zxvf openssl-0.9.7d.tar.gz
cd openssl-0.9.7d
./config
make
make test
ouput should be ‘OPENSSLDIR: “/usr/local/ssl” ‘
make install
——————————
======
Apache
======
tar xvfz httpd-2.0.55.tar.gz
cd httpd-2.0.55
./buildconf
./configure –prefix=/opt/installs/apache2 –enable-so –enable-rewrite –enable-ssl –with-ssl=/usr/local/ssl –enable-proxy
make
make install
——————————-
=======
Mod_Jk
=======
tar xvfz jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz
mkdir /opt/installs/tools
mv jakarta-tomcat-connectors-jk-1.2.5-src /mnt/installs/tools
cd /opt/installs/tools/jakarta-tomcat-connectors-jk-1.2.5-src/jk/native
./buildconf.sh
./configure –with-apxs=/opt/installs/apache2/bin/apxs
make
cp apache-2.0/mod_jk.so /opt/installs/apache2/modules
———————————
mkdir /opt/pgdata
chown postgres:postgres pgdata/
mkdir /opt/pginstalls
chown postgres:postgres pginstalls
mkdir /mnt/postgreslogs
mkdir pg_scripts_logs
cp postgresql-7.4.8.tar.gz /opt/pginstalls/
su postgres
cd pginstalls/
tar zxvf postgresql-7.4.8.tar.gz
cd po*
./configure
gmake
(as root execute the following line)
gmake install
vi ~/.bash_profile and edit PATH as follows
:$PATH:/usr/local/pgsql/bin
cd /opt/pgdata
mkdir data
cd /opt/postgreslogs
touch server.log postgres.log
chmod 777 *
initdb -D /opt/pgdata/data/
Create pgstart and shutdown scripts
——————————-
pgstart
———-
echo ” Starting Postgres 7.4.8…….”
nohup /usr/local/pgsql/bin/postmaster -i -c fsync=on -c sort_mem=8192 -c shared_buffers=200 -D /mnt/pgdata/data -N 100 </dev/null >>/opt/postgreslogs/server.log 2>>/opt/postgreslogs/postgres.log &
echo ” Started”
echo ” Type psql <database> to switch to your database”
———
pgshutdown
chmod +x pgstart pgshutdown
—–
/usr/local/pgsql/bin/pg_ctl stop -W -D /opt/pgdata/data -m fast
start the database serevr using
/opt/scripts/pgstart
and verify with
psql -l
or
netstat -nlp | grep 5432