Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install and Configure PHPMyAdmin on Elastic Beanstalk
container_commands:
01_install_pma:
test: test -n "$PMA_VER" && test ! -f /tmp/phpmyadmin.tar.gz
command: |
cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/${PMA_VER}/phpMyAdmin-${PMA_VER}-all-languages.tar.gz
wget https://files.phpmyadmin.net/phpMyAdmin/${PMA_VER}/phpMyAdmin-${PMA_VER}-all-languages.tar.gz.sha1
cd /tmp && sha1sum --check phpMyAdmin-${PMA_VER}-all-languages.tar.gz.sha1
if [[ $? == 0 ]]
then
cd /opt/ && tar xzf /tmp/phpMyAdmin-${PMA_VER}-all-languages.tar.gz && ln -s phpMyAdmin-${PMA_VER}-all-languages phpmyadmin
else
exit 1
fi
exit 0
02_create_config_file:
test: test ! -f /opt/phpmyadmin/config.inc.php
command: cd /opt/phpmyadmin && cp config.sample.inc.php config.inc.php
03_change_auth_type:
test: test -f /opt/phpmyadmin/config.inc.php
command: sed -i "s/'cookie'/\'config'/g" /opt/phpmyadmin/config.inc.php
04_configure_db_host:
test: test -f /opt/phpmyadmin/config.inc.php
command: sed -i "s/'localhost'/\$_SERVER['RDS_HOSTNAME']/g" /opt/phpmyadmin/config.inc.php
05_config_db_credentials:
command: |
grep -q "RDS_USERNAME" /opt/phpmyadmin/config.inc.php || sed -i "/RDS_HOSTNAME/i \
\$cfg['Servers'][\$i]['user'] = \$_SERVER['RDS_USERNAME'];\n\$cfg['Servers'][\$i]['password'] = \$_SERVER['RDS_PASSWORD'];" /opt/phpmyadmin/config.inc.php
06_configure_htauth:
test: test -n "$PMA_USERNAME" && test -n "$PMA_PASSWORD"
command: |
if [[ -f /etc/httpd/htpasswd ]]
then
htpasswd -b /etc/httpd/htpasswd $PMA_USERNAME $PMA_PASSWORD
else
htpasswd -cb /etc/httpd/htpasswd $PMA_USERNAME $PMA_PASSWORD
fi
files:
"/etc/httpd/conf.d/pma.conf":
mode: "000644"
owner: root
group: root
content: |
Alias /db_admin /opt/phpmyadmin
<Directory /opt/phpmyadmin>
AuthType Basic
AuthName "Restricted Files"
AuthBasicProvider file
AuthUserFile "/etc/httpd/htpasswd"
Require valid-user
Options FollowSymLinks
</Directory>
<Directory /opt/phpmyadmin/libraries/>
Require all denied
</Directory>
<Directory /opt/phpmyadmin/setup/lib/>
Require all denied
</Directory>
<Directory /opt/phpmyadmin/setup/frames/>
Require all denied
</Directory>
@canhnht

This comment has been minimized.

Copy link

canhnht commented Dec 13, 2016

This is really helpful. Thanks a lot 👍

@FractalMind

This comment has been minimized.

Copy link

FractalMind commented Feb 16, 2017

You sir are a gentleman and a scholar! +1

@codesignage

This comment has been minimized.

Copy link

codesignage commented Mar 8, 2019

Hi I'm able to get the phpmyadmin installed, but once I logged in, a warning

"The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this."

What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.