Skip to content

Instantly share code, notes, and snippets.

@simplyspoke
Created February 4, 2017 07:05
Show Gist options
  • Save simplyspoke/e416f5e3df7506f52a44543a4cd009f1 to your computer and use it in GitHub Desktop.
Save simplyspoke/e416f5e3df7506f52a44543a4cd009f1 to your computer and use it in GitHub Desktop.
Old AWS Hosting Solution
#!/bin/bash
sudo -i
sudo passwd root
userdel -rf ubuntu
perl -pi -e 's%(universe)$%$1 multiverse%' /etc/apt/sources.list
apt-get update && apt-get upgrade
apt-get install build-essential ec2-ami-tools ec2-api-tools euca2ools rpcbind nfs-kernel-server php5-cli php5-mysql php5-mcrypt php5-mcrypt php5-dev php-pear php5-curl cpipe
ec2attvol VOLUMNID -i INSTANCEID -d /dev/sdf
mkfs -t ext3 /dev/xvdf
mkdir /vol
mount /dev/xvdf /vol
echo "/dev/xvdf /vol ext3 noatime 0 0" | tee -a /etc/fstab
date
dpkg-reconfigure tzdata
date
type -a service
vi /etc/crontab
vi /etc/exports
vi /etc/fstab
vi /etc/logrotate.conf
ln -s /root/scripts/cronall /etc/cron.hourly/cronall
ln -s /root/scripts/server-permissions /etc/cron.hourly/server-permissions
ln -s /root/drush/drush /usr/local/bin/drush
chmod u+x /root/drush/drush
exportfs -a
service portmap start
/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start
#echo "/dev/sdf /vol xfs noatime 0 0" | tee -a /etc/fstab
#mkdir -m 000 /vol
#mount /vol
#echo "/vol/home /home none bind" | tee -a /etc/fstab echo "/dev/sdg / xfs noatime 0 0" | tee -a /etc/fstab
#rds-modify-db-parameter-group production --parameters="name=max_allowed_packet, value=16777216, method=immediate"
#rds-modify-db-instance INSTANCENAME --db-parameter-group-name=production
#rds-reboot-db-instance INSTANCENAME
#as-update-auto-scaling-group ProcessAutoScaleGroup --min-size 3 --max-size 10
#!/bin/bash
sudo -i
sudo passwd root
userdel -rf ubuntu
perl -pi -e 's%(universe)$%$1 multiverse%' /etc/apt/sources.list
apt-get update && apt-get -y upgrade
apt-get install -y apache2 php5-dev php-pear php5-curl php5-mcrypt php5-gd libapache2-mod-php5 mysql-client-5.5 build-essential ec2-ami-tools ec2-api-tools euca2ools autofs libpcre3-dev libio-socket-ssl-perl libxml-libxml-perl php5-mysql
aptitude install nfs-common portmap
aptitude install imagemagick
pecl install apc
pecl install uploadprogress-1.0.1
vi /etc/crontab
vi /etc/hosts
rm -R /root
rm -R /var/www
mkdir /root
mkdir /var/www
mount -t nfs 10.244.41.67:/vol/webserver/root /root
mount -t nfs 10.244.41.67:/vol/var/www /var/www
rm -R /etc/apache2
rm -R /etc/php5
mkdir /etc/apache2
mkdir /etc/php5
mount -t nfs 10.244.41.67:/vol/webserver/etc/apache2 /etc/apache2
mount -t nfs 10.244.41.67:/vol/webserver/etc/php5 /etc/php5
a2enmod rewrite ssl alias autoindex mime rewrite setenvif auth_basic cgi negotiation authn_file deflate ssl authz_default php5 authz_groupfile dir status authz_host reqtimeout authz_user env
vi /etc/fstab
dpkg-reconfigure tzdata
type -a service
#ec2-create-image IMAGEID --name fileserver_prescale --description "Serves filesystem to the processing instances" --region us-east-1a --no-reboot
#elb-create-lb ELBNAME --headers --listener "lb-port=443,instance-port=8443,protocol=TCP" --listener "lb-port=443,instance-port=8444,protocol=TCP" --listener "lb-port=80,instance-port=80,protocol=http" --availability-zones us-east-1a
as-create-launch-config launchweb --image-id ami-IMAGEID --instance-type m1.small --group GROUPNAME
as-create-auto-scaling-group webgroup --availability-zones us-east-1a --launch-configuration launchweb --min-size 1 --max-size 10 --load-balancers LOADBALENCER
as-put-scaling-policy scaleup --auto-scaling-group webgroup --adjustment=1 --type ChangeInCapacity --cooldown 120
mon-put-metric-alarm HighCPU --comparison-operator GreaterThanThreshold --evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" --period 120 --statistic Average --threshold 80 --alarm-actions arn:aws:autoscaling:us-east-1:ID:scalingPolicy:POLICYID:autoScalingGroupName/GROUPNAME:policyName/scaleup --dimensions "AutoScalingGroupName=GROUPNAME"
as-put-scaling-policy scaledown --auto-scaling-group webgroup --adjustment=-1 --type ChangeInCapacity --cooldown 120
mon-put-metric-alarm LowCPU --comparison-operator LessThanThreshold --evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" --period 120 --statistic Average --threshold 40 --alarm-actions arn:aws:autoscaling:us-east-1:ID:scalingPolicy:POLICYID:autoScalingGroupName/GROUPNAME:policyName/scaledown --dimensions "AutoScalingGroupName=GROUPNAME"
as-update-auto-scaling-group ProcessingGroup --launch-configuration LaunchWeb
#!/bin/bash
echo "Please enter the domain name for the site: "
read domain_name
echo "Please enter the development subdomain for the site: "
read development_name
echo "Please enter the database name for the site: "
read database_name
echo "Please enter the root MYSQL password: "
read root_mysql
echo "Please enter the site_access MYSQL password: "
read access_mysql
echo "Please enter admin name for the site: "
read admin_name
echo "Please enter admin password for the site: "
read admin_password
echo "You entered the following information.
Domain name: $domain_name
Development subdomain: $development_name
Database name: $database_name
Admin name: $admin_name
Admin password: $admin_password
"
read -p "Are these correct? (y/n) " confirm_names
if [ "$confirm_names" = "y" ]; then
sed -e "s;%domain_name%;$domain_name;" -e "s;%development_name%;$development_name;" /home/{USERNAME}/scripts/site-files/vhost.txt > /etc/apache2/sites-available/$domain_name
mkdir -v /var/www/vhosts/$domain_name
mkdir -v /var/www/vhosts/$domain_name/httpdocs
mkdir -v /var/www/vhosts/$domain_name/logs
mkdir -v /var/www/vhosts/$domain_name/tmp
cd /var/www/vhosts/$domain_name/httpdocs
#SQL="CREATE DATABASE IF NOT EXISTS $database_name;GRANT ALL ON $database_name.* TO 'site_access'@'localhost' IDENTIFIED BY '$access_mysql';FLUSH PRIVILEGES;"
#mysql -u root -p$root_mysql -e "$SQL"
drush -r /var/www/vhosts/$domain_name/httpdocs dl drupal-7.12
mv /var/www/vhosts/$domain_name/httpdocs/drupal-7.12/* /var/www/vhosts/$domain_name/httpdocs/
rm -R /var/www/vhosts/$domain_name/httpdocs/drupal-7.12
drush -r /var/www/vhosts/$domain_name/httpdocs site-install standard --account-name=$admin_name --account-pass=$admin_password --db-su=root --db-su-pw=$root_mysql --db-url=mysql://site_access:$access_mysql@localhost/$database_name
echo "\ndrush -r /var/www/vhosts/$domain_name/httpdocs cron" >> /home/trijeda/scripts/cronall
sh /home/{USERNAME}/scripts/server-permissions
a2ensite $domain_name
echo "Your site has been configured! Don't forget to:
- Check all the files and database to make sure everything is there.
- Change the .htaccess file to enable www rewriting.
- Restart your apache installation wiht service apache2 restart.
Enjoy!"
else
echo "Site setup and configuration aborted"
fi
<VirtualHost *:80>
ServerName %development_name%.example.com:80
ServerAlias %development_name%.example.com
DocumentRoot /var/www/vhosts/%domain_name%/httpdocs
CustomLog /var/www/vhosts/%domain_name%/logs/access_log combined
ErrorLog /var/www/vhosts/%domain_name%/logs/error_log
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory /var/www/vhosts/%domain_name%/httpdocs>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
</IfModule>
Options -Includes +ExecCGI
</Directory>
# Read in the drupal configuration
# Include /etc/apache2/custom/drupal_6.conf
</VirtualHost>
#<VirtualHost *:80>
# ServerName %domain_name%:80
# ServerAlias %domain_name% www.%domain_name%
# DocumentRoot /var/www/vhosts/%domain_name%/httpdocs
# CustomLog /var/www/vhosts/%domain_name%/logs/access_log combined
# ErrorLog /var/www/vhosts/%domain_name%/logs/error_log
# <IfModule mod_ssl.c>
# SSLEngine off
# </IfModule>
# <Directory /var/www/vhosts/%domain_name%/httpdocs>
# <IfModule mod_php5.c>
# php_admin_flag engine on
# php_admin_flag safe_mode off
# </IfModule>
# Options -Includes +ExecCGI
# </Directory>
# # Read in the drupal configuration
# # Include /etc/apache2/custom/drupal_6.conf
#</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment