Azure App Service on Linux – mysql and mysqli driver

Azure Web App / Azure App Service on Linux by default do not offer mysql and mysqli driver to connect to MySQL database. The lowest PHP version is 5.6. Sometimes you need to move to the cloud older application.

If your application uses MySQL driver you probably see an error like this:

ErrorException [ Fatal Error ]: Call to undefined function mysql_connect()

So here is an example of how to install the extension to the Azure App Service on Linux, that it is similar to the Windows one. I add MySQL driver to Web App / Azure App Service on Linux, but in a similar way, you can add other extensions.

First, go to Configuration Tab and in configuration settings add PHP_INI_SCAN_DIR where you add files with the configuration of your extensions.

In this example, I added /home/site/ini.

Next, add the directory in your (/home/site/ini) Web App (you can use SSH access or FTP) I suggest to create another directory like /home/site/ext where you put binaries of your extensions.

Finally in /home/site/ini put file .extensions with configuration like:

extension=/home/site/ext/mysql.so

and in /home/site/ext put binary of your extension.

It should look like this:

After putting files please STOP and Start your App Service and extension should be loaded. Please consult your Log Streaming that application is restarted. If you need to compile your own extensions please consult the version of Apache and system in logs, like here:

You can get operating system version by issuing: cat /etc/os-release

Here are examples files that you can use to add mysql driver and mysqli driver:

WebAppMySQLMySQLiExtensions