This script is used to start a instance in ec2, you can extended this script in the way you want, we keep on posting new scripts to work with ec2
#!/bin/bash
export EC2_HOME=/home/sandeep/ec2/ec2-api-tools-1.3-46266
PATH=$EC2_HOME/bin:$PATH
export EC2_PRIVATE_KEY=/home/sandeep/ec2/pk-XXXXXXXXXXXXXXXXXXXXXXXX.pem
export EC2_CERT=/home/sandeep/ec2/cert-XXXXXXXXXXXXXXXXXXXXXXXX.pem
export EC2_URL=https://us-east-1.ec2.amazonaws.com
export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre/
export amiid="ami-0d5db264"
export key="xxxxsshkeyxxxx"
export zone="us-east-1d"
export id_file="/home/sandeep/ec2/keyxxx.pem"
export group="default"
#
# Start the instance
#
echo Launching AMI ${amiid}
${EC2_HOME}/bin/ec2-run-instances ${amiid} -z ${zone}
-k ${key} --group ${group} > /tmp/a
if [ $? != 0 ]; then
echo "Error starting instance for image" ${amiid}
exit 1
fi
export iid=`cat /tmp/a | grep INSTANCE | cut -f2`
#
# Loop until the status changes to 'running'
#
sleep 30
echo Starting instance ${iid}
export RUNNING="running"
export done="false"
while [ $done == "false" ]
do
export status=`${EC2_HOME}/bin/ec2-describe-instances ${iid} | grep INSTANCE | cut -f6`
if [ $status == ${RUNNING} ]; then
export done="true"
else
echo Waiting...
sleep 10
fi
done
echo Instance ${iid} is runningPlease feel free to post any comments or errors XX
Many of our dynamic sites contain rarely updated content (ex. blog archive page). By adding nginx server as proxy server infront of your apache server you can server those pages like static pages instead of running the page for every request, this will boost your site speed from 50% - 400%. We need apache, nginx to work with this tutorial To install nginx on debian please follow this link http://timothybowler.com/2009/11/25/compiling-nginx-on-debian-lenny/ Note: Dont install using aptitude it contains older version where gzip and proxy module not available, Modify apache ports.conf to run apache on port 8080 Add this lines to default site of nginx [shell]
server { listen 80; server_name debianzone.com; location / { proxy_pass http://debianzone.com:8080; proxy_cache debianzone-cache; proxy_cache_valid 200 302 60m; proxy_cache_valid 404 1m; } } [/shell] Add this in http section of nginx.conf[shell] http { proxy_cache_path /var/www/cache levels=1:2 keys_zone=debianzone-cache:8m max_size=1000m inactive=600m; proxy_temp_path /var/www/cache/tmp; }
[/shell]
ctrl + shift + i
/bin/hostname your-host-name
/etc/hostname /etc/init.d/hostname.sh start