Skip to content

Instantly share code, notes, and snippets.

@canhnht
Forked from Azrael808/phpmyadmin.config
Created December 13, 2016 02:57
Show Gist options
  • Save canhnht/a9bc98f81de0a34aba3ade71f72a23a0 to your computer and use it in GitHub Desktop.
Save canhnht/a9bc98f81de0a34aba3ade71f72a23a0 to your computer and use it in GitHub Desktop.

Revisions

  1. @Azrael808 Azrael808 created this gist Mar 2, 2016.
    67 changes: 67 additions & 0 deletions phpmyadmin.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    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>