Skip to content

Instantly share code, notes, and snippets.

@malilovick
Forked from sarath2/Setup.md
Last active August 29, 2015 14:10
Show Gist options
  • Save malilovick/32d65c9d28886b0061ef to your computer and use it in GitHub Desktop.
Save malilovick/32d65c9d28886b0061ef to your computer and use it in GitHub Desktop.

#Launch an instance http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/GetStarted.html

#Setup EC2

chmod 400 key.pem
ssh -i key.pem ec2-user@YOUR_SERVER_IP

##Root login

sudo -i

##Update and install

sudo yum -y update
sudo yum install -y gcc make gcc-c++
sudo yum install -y php55-mysqlnd php55 php55-xml php55-mcrypt php55-mbstring php55-cli mysql55 mysql55-server httpd24

-y will tell yum to say yes to all questions.

##Start your engines

sudo service httpd start
sudo service mysqld start

##MySQL Setup

sudo /usr/bin/mysqladmin -u root password SUPERSECUREPASSWORD

##Setup startup scripts for apache and MySQL

cd /etc/rc.d/rc3.d
sudo rm K15httpd
sudo rm K36mysqld
sudo ln -s ../init.d/mysqld S30mysql
sudo ln -s ../init.d/httpd S85httpd

##Install phpMyAdmin

cd /var/www/html
sudo wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.1.7/phpMyAdmin-4.1.7-all-languages.tar.gz
sudo tar -xzvf phpMyAdmin-4.1.7-all-languages.tar.gz -C /var/www/html
sudo mv phpMyAdmin-4.1.7-all-languages phpmyadmin
sudo rm -rf phpMyAdmin-4.1.7-all-languages.tar.gz

check for updates: http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/

We now need to add permission for this folder, find the user group (should be apache) with this command:

egrep 'User|Group' /etc/httpd/conf/httpd.conf

Which will return:

User apache
Group apache

And last, run this command to associate that user with the phpmyadmin folder:

sudo chown -R apache.apache phpmyadmin/

##Install Config

cd /var/www/html/phpmyadmin/
sudo cp config.sample.inc.php config.inc.php
sudo mkdir config
sudo chmod o+rw config
sudo cp config.sample.inc.php config/config.inc.php
sudo chmod o+w config/config.inc.php

##Setup Config

sudo nano /var/www/html/phpmyadmin/config.inc.php
$cfg['blowfish_secret'] = '{^QP+-(3mlHy+Gd~FE3mN{gIATs^1lX+T=KVYv{ubK*U0V';

reference: http://www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator

##Restart Server

sudo service httpd restart

##Setup phpMyAdmin

http://YOUR_SERVER_IP/phpmyadmin/index.php

with username root password SUPERSECUREPASSWORD

##Remove config folder

sudo rm -rf config

#Setup RDS Setup RDS with username awsuser password mypassword

##Edit Config

sudo nano /var/www/html/phpmyadmin/config.inc.php
$cfg['Servers'][$i]['host'] = 'mydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com:3306'

##Access phpMyAdmin

http://YOUR_SERVER_IP/phpmyadmin/index.php

with username awsuser password mypassword

##phpinfo

sudo nano /var/www/html/info.php
<?php phpinfo(); ?>

##Test db connection

sudo nano /var/www/html/db_test.php
$link = mysqli_connect('mydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com', 'awsuser', 'mypassword', 'information_schema', 3306);
var_dump($link);
$link = mysqli_connect('localhost', 'root', 'SUPERSECUREPASSWORD', 'information_schema');
var_dump($link);

#Git Depoly https://gist.github.com/oodavid/1809044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment