Create a gist now

Instantly share code, notes, and snippets.

@suvozit /
Last active Oct 30, 2017

What would you like to do?
Setup AWS EC2 and RDS (php5.5, apache2.4, mysql5.5, phpmyadmin)

Launch an instance

Security group



Type Protocol Port Range Destination

Assign phpMyAdmin to the new EC2 instance and visit


Setup EC2

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

Root login

sudo -i

Update and install

yum -y update
yum install -y gcc make gcc-c++
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

service httpd start
service mysqld start

MySQL Setup

/usr/bin/mysqladmin -u root password SUPERSECUREPASSWORD

Setup startup scripts for apache and MySQL

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

Install phpMyAdmin

cd /var/www/html
tar -xzvf phpMyAdmin- -C /var/www/html
mv phpMyAdmin- phpmyadmin
rm -rf phpMyAdmin-

check for updates:

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:

chown -R apache.apache phpmyadmin/

Install Config

cd /var/www/html/phpmyadmin/
mkdir config
chmod o+rw config
cp config/
chmod o+w config/

Setup Config

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


Restart Server

service httpd restart

Setup phpMyAdmin


with username root password SUPERSECUREPASSWORD

Remove config folder

rm -rf config

Setup RDS

Setup RDS with username awsuser password mypassword

Security group


Type Protocol Port Range Source
MYSQL/Aurora TCP 3306 sg-abcdefgh (phpMyAdmin)

Connect to RDS

Edit Config

nano /var/www/html/phpmyadmin/
$cfg['Servers'][$i]['host'] = ''

Access phpMyAdmin


with username awsuser password mypassword


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

Test db connection

nano /var/www/html/db_test.php
$link = mysqli_connect('', 'awsuser', 'mypassword', 'information_schema', 3306);
$link = mysqli_connect('localhost', 'root', 'SUPERSECUREPASSWORD', 'information_schema');

#Git Deploy

lmon commented Dec 16, 2014

thank you!
(you have a typo: "Git Depoly" should be "Git Deploy") 😄

sudo yum install -y php55-mysqlnd php55 php55-xml php55-mcrypt php55-mbstring php55-cli mysql55 mysql55-server httpd24

sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"

What are the difference between these two scripts? currently, I'm using ec2 to host a Wordpress site with your server script to setup which is nice, but the script looks missed sth that "groupinstall" has. How can I do the groupinstall to connect the RDS plus install the phpmyadmin?? cuz I tried the groupinstall and it failed to connect the RDS and install phpmyadmin, please help.

Thank you =)

This is awesome, thank you! I've been struggling with getting php 5.5 running on ec2 and this process worked flawlessly.

RoyLiou commented Apr 16, 2015

So cool! thank you.

Very helpful, thank you.

Brilliant stuff.. thanks a lot

i am executing this command service mysqld start it getting error comman not unrecongnised service

How do I create an ALIAS for phpmyadmin, for security reasons

Thanks very much, A great help!!

Tyvm! On the last step, I tried http://YOUR_SERVER_IP/db_test.php with my ec2's url. The browser returns: object(mysqli)#1 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $" ["client_version"]=> int(50011) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(61) " via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(10) "5.6.23-log" ["server_version"]=> int(50623) ["stat"]=> string(134) "Uptime: 8363 Threads: 2 Questions: 4473 Slow queries: 0 Opens: 81 Flush tables: 1 Open tables: 74 Queries per second avg: 0.534" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(74) ["warning_count"]=> int(0) }

What happened?

makkaba commented Apr 16, 2016

thanks a lot !!

Hey buddy, am having some issues can I hire you to set things up? the wordpress is already done, but not able to connect to existing database, please email: awesome(dot)info@creativefriends(dot)asia

jeffmcneill commented Jul 29, 2017

Install PhpMyAdmin from the Amazon EPEL Repository, after Enabling EPEL:

yum-config-manager --enable epel
yum install phpmyadmin

Edit the file /etc/httpd/conf.d/phpMyAdmin.conf and replace with the ip address of the client.

nano /etc/httpd/conf.d/phpMyAdmin.conf

Restart the web server

service httpd restart

Test to see if it works

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