Deploying Adminer on Google App Engine (GAE) with Private and Public IP Connectivity
Tags: googlecloud, devops, sql, tutorial
Published: 2023-11-17 14:26:17

## Adminer
[Adminer](https://www.adminer.org/) (formerly phpMinAdmin) is a full-featured database management tool written in PHP. Unlike phpMyAdmin, it offers a single-file deployment, making it highly convenient for target servers. Adminer supports various databases, including MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Elasticsearch, MongoDB, and more through plugins. Its simplicity and broad compatibility make Adminer an efficient choice for database management.

This guide will walk you through deploying Adminer on Google App Engine standard environment, allowing you to connect to SQL servers using both Private and Public IPs.

## Prerequisites

Before getting started, make sure you have the following:
- A Google Cloud Platform account.
- Basic knowledge of GCP services.

## Step 1: Set up a GCP Project

1. Open the [Google Cloud Console](https://console.cloud.google.com/).
2. Create a new project or select an existing one.

## Step 2: Enable App Engine API

1. Navigate to the `App Engine` section in the Google Cloud Console.
2. Enable App Engine for your project if it's not already enabled.


## Step 3: Download the Adminer

You'll deploy [Adminer](https://www.adminer.org/en/) as a service of your App Engine Standard application, so you must download the source code for Adminer. Follow these steps:

1. Open the Cloud Shell Terminal by navigating to the `Cloud Shell`  or press `g+s` to open the Cloud Shell using the shortcut. Alternatively, you can use the Google Cloud SDK installed on your local machine.
2. In the terminal, create a new directory named `Adminer` and enter the following commands to download `Adminer version 4.8.1` and save it as `index.php`.
```bash
mkdir Adminer
cd Adminer
wget https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php -O index.php
```
To use a different version of Adminer, use the links to available versions on the [Adminer Downloads page](https://github.com/vrana/adminer/releases).


## Step 3: Prepare the Adminer files for deployment

In the directory that you created, named `Adminer`, create a new file named `app.yaml` file for App Engine configuration:

- For Public IP connection to SQL server use the below `app.yaml` file.
```yaml
service: adminer
runtime: php82
 
handlers:
- url: /.*
  script: index.php
```

- For Private IP connection to SQL server use the below `app.yaml` file.
```yaml
service: adminer
runtime: php82
 
handlers:
- url: /.*
  script: index.php

vpc_access_connector:
 name: projects/PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAME
```

> Where `PROJECT_ID` is your Google Cloud project ID, `REGION` is the region your connector is in, and `CONNECTOR_NAME` is the name of your [Serverless VPC Access connector](https://cloud.google.com/appengine/docs/standard/connecting-vpc#console).

If you are deploying Adminer as the first and only application in App Engine, change the value for service from Adminer to default.

Normally, you would deploy phpMyAdmin as a service of an existing application and provide a name for the service. However, if you haven't yet deployed an application, then you are required to use the service name "default". That's fine for the purposes of this tutorial if you're trying out phpMyAdmin on App Engine.


## Step 4: Deploy the application to App Engine:

Deploy the application by running the following command from within the Adminer directory where your `app.yaml` file is located:

```bash
gcloud app deploy --version=VERSION_ID
```
> Replace `VERSION_ID` with the latest version


## Step 5: Log in to Adminer

Once the deployment is complete, you can access Adminer in your web browser at 
`https://adminer-dot-[YOUR_APP_ID].appspot.com`

## Step 6: Clean Up (Optional)

If you want to clean up App Engine resources after testing:

```bash
gcloud app versions delete VERSION_ID
```
> Replace `VERSION_ID` with the version you want to delete

## Conclusion

Congratulations! You have successfully deployed Adminer on Google App Engine. Access your Adminer instance by navigating to the provided App Engine URL, and start managing your databases with ease.

Feel the freedom to tailor the deployment to suit your unique specifications. Enjoy your coding adventures, and don't forget to show some love for open source!

Extend your support to the ingenious mind behind Adminer, **Jakub Vrána**, by contributing to the dance of creativity on **[Patreon](https://www.patreon.com/jakubvrana)**. Your generosity keeps the rhythm alive!

## Let's Connect!
Feel the vibe and join the conversation. Your questions, ideas, and thoughts are not just welcomed but cherished. 🚀
**&emsp;🌐 [LinkedIn](https://www.linkedin.com/in/sarath-p-m)
&emsp;🚀 [GitHub](https://github.com/sarath-pm)**