Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msimecek/webapps-php-mysql-redirect
Setting up the Redirect functionality for Azure MySQL/MariaDB and PHP on Azure Web Apps. Using the mysqlnd_azure driver.
https://github.com/msimecek/webapps-php-mysql-redirect
prototype
Last synced: 11 days ago
JSON representation
Setting up the Redirect functionality for Azure MySQL/MariaDB and PHP on Azure Web Apps. Using the mysqlnd_azure driver.
- Host: GitHub
- URL: https://github.com/msimecek/webapps-php-mysql-redirect
- Owner: msimecek
- Created: 2020-11-30T09:17:12.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-30T10:48:25.000Z (about 4 years ago)
- Last Synced: 2025-01-19T02:05:55.926Z (12 days ago)
- Topics: prototype
- Language: Shell
- Homepage:
- Size: 131 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Azure Redirect for Azure MySQL/MariaDB on Linux Azure Web Apps PHP 7.4 without Docker
This approach is using the mysqlnd_azure.so extension to enable the [redirection functionality](https://docs.microsoft.com/azure/mariadb/howto-redirection) on Azure MySQL/MariaDB instance.
1. Build the *mysqlnd_azure.so* binary with `make` (using Docker container or locally). You can follow [these steps](https://github.com/microsoft/mysqlnd_azure#step-to-build-on-linux).
```bash
# Using the appsvc/php:7.4-apache_20200522.6 Docker image.
apt install git -y
git clone https://github.com/microsoft/mysqlnd_azure --depth 1
cd mysqlnd_azure
phpize
./configure
make
# If successful, the binary will be in ./modules/mysqlnd_azure.so.
```1. Extract the binary from the container (if using Docker): `docker cp :/home/mysqlnd_azure/modules/mysqlnd_azure.so `.
1. Add the newly created binary to your project (for instance to a `./bin` folder).
1. Create a configuration INI file (for instance in an `./ini` folder).
1. Add the following to the file:```ini
extension=/home/site/wwwroot/bin/mysqlnd_azure.so
mysqlnd_azure.enableRedirect = on
```1. [Change the INI scan directory](https://docs.microsoft.com/azure/app-service/configure-language-php?pivots=platform-linux#customize-php_ini_system-directives) for your Web App.
```bash
az webapp config appsettings set --name --resource-group --settings PHP_INI_SCAN_DIR="/usr/local/etc/php/conf.d:/home/site/wwwroot/ini"
```> Note: This is a simplistic approach. Microsoft documentation recommends creating the `ini` folder outside of `wwwroot` using SSH.
1. Push to the repo and deploy the app.
1. Don't fogert to change the `redirect_enabled` setting to *ON* on you Azure MySQL/MariaDB instance.The directory structure then can look like this:
```
|- bin
|-mysqlnd_azure.so
|- ini
|-mysqlnd_setting.ini
|- index.php
```Finally, test the connection via PHP:
```php
host_info, "\n"; //if redirection succeeds, the host_info will differ from the hostname you used used to connect
$res = $db->query('SHOW TABLES;'); //test query with the connection
print_r ($res);
$db->close();
}
?>
```