Cloud Init PHP7 w/ PHPMyAdmin

June 10, 2016 455 views
LAMP Stack Deployment PHP System Tools Quickstart Server Optimization DigitalOcean Ubuntu

Why doesn't this work as a cloud init user script for PHP7 and PHPMyAdmin?

apt_update: true
package_upgrade: true
  - apache2
  - apache2-utils
  - php7-mysql
  - mysql-server
  - libapache2-mod-php7
  - php7-mcrypt
  - php7-gd
  - php7-curl
  - phpmyadmin
  - path: /usr/share/phpmyadmin/.htaccess
    content: |
      AuthType Basic
      AuthName "Restricted Files"
      AuthUserFile /etc/phpmyadmin/.htpasswd
      Require valid-user
  # Configure Apache
  - php7enmod mcrypt
  - sed -i -e "s/index.html index.cgi index.php/index.php index.html index.cgi" /etc/apache2/mods-enabled/dir.conf
  - sed -i -e "s/index.php/index.php\n\tAllowOverride\ All/" /etc/phpmyadmin/apache.conf
  - ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

  # Generate random passwords for the MySql root user and the .htaccess file
  - PHPMYADMINPASS=`dd if=/dev/urandom bs=1 count=12 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev`
  - MYSQLPASS=`dd if=/dev/urandom bs=1 count=12 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev`
  - mysqladmin -u root -h localhost password "$MYSQLPASS"
  - echo "[client]\npassword="$MYSQLPASS"\n" > /root/.my.cnf
  # The .htaccess username defaults to phpmyadmin. Update the line below to change that.
  - echo $PHPMYADMINPASS | htpasswd -c -i /etc/phpmyadmin/.htpasswd phpmyadmin
  - echo "phpMyAdmin Password -    "$PHPMYADMINPASS"" > /root/phpmyadmin
  - echo "MySql Password      -    ""$MYSQLPASS""" >> /root/phpmyadmin

  # Enable the conf and restart Apache.
  - a2enconf phpmyadmin.conf
  - service apache2 restart
  • Any anomalies show up in the cloud-init-output.log file?

  • What is your distro/version?

    One thing I see - I believe you need to set environment variables with:

    export PHPMYADMINPASS=`blah`

    try prepending any lines where you are setting environment variables with export

Be the first one to answer this question.