Skip to content

Instantly share code, notes, and snippets.

@Azrael808
Created March 2, 2016 20:03
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Azrael808/858e98c4225622ed2e74 to your computer and use it in GitHub Desktop.
Save Azrael808/858e98c4225622ed2e74 to your computer and use it in GitHub Desktop.
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
Copy link

canhnht commented Dec 13, 2016

This is really helpful. Thanks a lot 👍

@FractalMind
Copy link

You sir are a gentleman and a scholar! +1

@codesignage
Copy link

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