Did you know that you can navigate the posts by swiping left and right?

Configuring custom domains on Github Pages (Part 3)

02 Apr 2019 . Category: tutorial . Comments

Configure and use PHPMyAdmin with Heroku using JawsDB

On the last tutorial I teached you how to configure your first PHP backend using Heroku, now we will introduce PHPMyAdmin on Heroku.

For this, I used this amazing Heroku template to use PHPMyAdmin by smsaladi. You just need to copy the following lines into your composer:

  "scripts" : {
    "post-install-cmd" : "composer create-project phpmyadmin/phpmyadmin; cp config.inc.php phpmyadmin/"
  }

and inside the require part:

"ext-mbstring": "*"

Also, you’ll need to copy the config.inc.php into the root of your Heroku project.

You’ll need to modify the “post-install-cmd” if you want to use a subfolder pointing to a subdomain as I done on the Part 2:

Modify the “post-install-cmd” to match this:

cd web/ && composer create-project phpmyadmin/phpmyadmin; cp ../config.inc.php phpmyadmin/

And create the phpmyadmin folder inside the web one.

Note: If you want to point to a subdomain instead of using the folder, make sure you configured correctly your DNS records at Cloudflare and copy the proper part from my .htaccess in the example of the Part 2.

Then, execute the following commands:

$ composer update
$ git add .
$ git commit -m "Deploying PHPMyAdmin"
% git push heroku master

Configuring JawsDB

To configure JawsDB, you’ll need to follow the steps on the Heroku guide about this.

I only used this two commands from this guide:

$ heroku addons:create jawsdb

To add the addon.

$ heroku config:get JAWSDB_URL

To get your credentials that you will need to use in PHPMyAdmin.

Configuring environment variables

PHPMyAdmin’s config.inc.php file will need two environment variables:

To generate the blowfish secret, just use a SHA-1 or MD5 hash generators (that doesn’t store on its database :joy:, for example sha1-online.com). Once you created one just set it using this command:

$ heroku config:set PHPMYADMIN_BLOWFISH_SECRET=<hash>

The MYSQL_HOST variable can be extracted from the heroku config:get JAWSDB_URL I explained before. Just follow its format (mysql://username:password@hostname:port/default_schema)

And set it as I explained before for the “PHPMYADMIN_BLOWFISH_SECRET” key.

Can’t login using SSL?

Well, that behaviour would be expected if you’re using Heroku for free and Cloudflare with SSL.

If you followed the Part 2 of this tutorial, you’ll need to unset the “Always Use HTTPS” option under Crypto on your dashboard and create some rules to keep users redirecting to https:

  • https://sql.example.com/
    • Rule => SSL: Off
  • http://*example.com/*
    • Rule => Always Use HTTPS

Click “Save and Deploy”.

Important Tip: Don’t login in your DDBB on a public Wifi due to a possible MitM attack.

Best regards!