Skip to content

Instantly share code, notes, and snippets.

@strongjz
Created October 16, 2014 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strongjz/f7d30e9f495126d2d0da to your computer and use it in GitHub Desktop.
Save strongjz/f7d30e9f495126d2d0da to your computer and use it in GitHub Desktop.
sample init script for connecting ec2 phpmyadmin to rds instance
#!/bin/bash
# User Data Script for Bootstrapping Lab - Architecting on AWS : Advanced Concepts
# Enable EPEL Repo
# This step is using sed, a standard Linux stream editor, to change the value of one line in a configuration file
# Reference: http://www.gnu.org/software/sed/manual/sed.html
/bin/sed -i '0,/enabled\=0/{s/0/1/}' /etc/yum.repos.d/epel.repo
# Install PHPMyAdmin
# This step is using yum, the Amazon Linux package manager, to install PHPMyAdmin and all of its components
# Reference: http://www.linuxcommand.org/man_pages/yum8.html
# Reference: http://en.wikipedia.org/wiki/Yellowdog_Updater,_Modified
/usr/bin/yum -y install mysql-server php55 php55 php55 phpMyAdmin
# Set up credentials for local mysql
/sbin/service mysqld start
/usr/bin/mysqladmin -u root password 'mysqlpassword'
# Configure PHPMyAdmin to be open to the Internet - replacing original configuration with one we are downloading from S3
/bin/cp /etc/httpd/conf.d/phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf.original
/usr/bin/wget -O /etc/httpd/conf.d/phpMyAdmin.conf https://us-west-2-aws-training.s3.amazonaws.com/architecting-advanced/v1.3/lab-4-bootstrapping-network-architecture/scripts/bootstrapping-etc-httpd-confd-phpMyAdmin.conf
# RDS Configuration for PHPMyAdmin
# ********************************
# You Must Configure These Variables
/bin/cp /etc/phpMyAdmin/config.inc.php /etc/phpMyAdmin/config.inc.php.original
/usr/bin/wget -O /etc/phpMyAdmin/config.inc.php https://us-west-2-aws-training.s3.amazonaws.com/architecting-advanced/v1.3/lab-4-bootstrapping-network-architecture/scripts/bootstrapping-s3bucket-etc-phpMyAdmin-config.inc.php
#CFGHOST="qm16ta89qnrolns.cx4iyh8swx0s.us-east-1.rds.amazonaws.com"
CFGHOST="qmcbhq2cn8laq3.cku6rbxuhm6s.us-west-2.rds.amazonaws.com"
CFGUSER="MyName"
CFGPASS="MyPassword"
/bin/sed -i "0,/ZZZZ9999/{s/ZZZZ9999/$CFGHOST/}" /etc/phpMyAdmin/config.inc.php
/bin/sed -i "0,/YYYY8888/{s/YYYY8888/$CFGUSER/}" /etc/phpMyAdmin/config.inc.php
/bin/sed -i "0,/XXXX7777/{s/XXXX7777/$CFGPASS/}" /etc/phpMyAdmin/config.inc.php
# Restart Apache to apply changes
/sbin/service httpd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment