-
-
Save danishbacker/5683bd1081519aa97b32c575e281f28a to your computer and use it in GitHub Desktop.
Install and Configure PHPMyAdmin on Elastic Beanstalk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment