This guide explains how to prepare Azure App Service to host City School and use Azure Database for MySQL — Flexible Server as the database.
Azure App Service supports PHP applications on Linux, and Laravel applications can use the public directory as the web root.
Prerequisites
Before starting, you need:
- An active Microsoft Azure subscription
- A domain name
- Basic knowledge of PHP and Laravel
- Access to the Azure Portal
- Your City School application files
Step 1 — Create a Resource Group
Sign in to the Azure Portal.
Search for Resource groups and select Create.
Enter a name such as:
rg-cityschool
Choose the Azure region closest to your users.
Select Review + create, then select Create.
Step 2 — Create an App Service Plan
In the Azure Portal, search for:
App Service Plans
Select Create.
Choose the resource group:
rg-cityschool
Enter a plan name such as:
plan-cityschool
For the operating system, select:
Linux
Choose an appropriate pricing tier based on your City School workload.
The App Service plan provides the compute resources used by the application.
Step 3 — Create the App Service
Open App Services and select Create → Web App.
Configure the application as follows:
Subscription: Your Azure subscription
Resource Group:
rg-cityschool
Name:
cityschool
The application name must be globally unique because Azure will initially provide a URL similar to:
For Publish, select:
Code
For Runtime stack, select a PHP version supported by your City School release.
For Operating System, select:
Linux
For Region, select the same region used for the App Service plan.
Select the App Service plan you created earlier.
Then select Review + create and Create.
Azure App Service currently supports PHP on Linux, while PHP on Windows App Service is not supported.
Step 4 — Configure the PHP Version
Open your newly created App Service.
Go to:
Settings → Configuration
Verify that the selected PHP runtime matches the requirements of your City School release.
City School should use a PHP version supported by the application and its dependencies.
Step 5 — Create Azure Database for MySQL
In the Azure Portal, search for:
Azure Database for MySQL servers
Create a new Flexible Server.
Use the same resource group:
rg-cityschool
Enter a server name such as:
cityschool-mysql
Choose the same Azure region as the App Service.
Select a MySQL version supported by your City School release.
Create a strong administrator username and password.
Step 6 — Configure MySQL Connectivity
For production deployments, configure MySQL connectivity so that the database is not unnecessarily exposed to the public internet.
Azure Database for MySQL Flexible Server supports both public access and private access through virtual networking.
When using public access, configure firewall rules to allow only the required connections.
For a private architecture, integrate the App Service with the appropriate Azure virtual network and configure the MySQL Flexible Server accordingly.
Step 7 — Create the City School Database
After the MySQL server is created, open:
Databases → Add
Create:
cityschool
Use the database name, administrator username, password, and server hostname when configuring City School.
Step 8 — Configure App Service Environment Variables
Open your App Service and go to:
Settings → Environment variables
Add the environment variables required by City School.
For a typical Laravel application, values will look similar to:
APP_ENV=production
APP_DEBUG=false
DB_CONNECTION=mysql
DB_HOST=YOUR_MYSQL_SERVER
DB_PORT=3306
DB_DATABASE=cityschool
DB_USERNAME=YOUR_MYSQL_USERNAME
DB_PASSWORD=YOUR_MYSQL_PASSWORD
Do not place production database passwords directly in the application’s source code.
Azure App Service allows application settings to be stored outside the application code and exposed to PHP applications as environment variables.
Step 9 — Configure the City School Web Root
Laravel applications use the public directory as the web root.
Azure’s PHP App Service documentation provides configuration methods for changing the site root to:
/home/site/wwwroot/public
This prevents the application root and sensitive files from being directly served by the web server.
For the Linux PHP App Service environment, configure the Nginx site root so that it points to:
/home/site/wwwroot/public
If a custom Nginx configuration is used, ensure requests are routed through:
index.php
Step 10 — Deploy City School
Deploy the City School files to the App Service using your preferred deployment method, such as:
- GitHub Actions
- Azure DevOps
- ZIP deployment
- Azure CLI
The deployed application should be located under:
/home/site/wwwroot
The public directory should be available at:
/home/site/wwwroot/public
Step 11 — Install Dependencies
After deployment, access the App Service SSH console.
Navigate to:
cd /home/site/wwwroot
Install the application’s Composer dependencies according to the City School installation requirements.
For a Laravel application, this commonly involves:
composer install --no-dev --optimize-autoloader
Run this only if Composer dependencies are not already installed as part of your deployment process.
Step 12 — Run Database Migrations
From the App Service SSH console:
cd /home/site/wwwroot
Then run:
php artisan migrate --force
Azure’s Laravel documentation demonstrates running migrations directly inside the App Service environment.
Use the database migration commands required by your City School release if they differ.
Step 13 — Configure Application Storage and Cache
For Laravel-based City School installations, configure the required application storage and cache settings according to the release documentation.
For example:
php artisan storage:link
Then clear and rebuild the application caches where required:
php artisan config:cache
php artisan route:cache
php artisan view:cache
Only run commands that are compatible with your City School version.
Step 14 — Configure the Custom Domain
Open the App Service and select:
Settings → Custom domains
Add your domain name.
Azure will provide the DNS records required to point your domain to the App Service.
Update the DNS records at your domain provider.
Once DNS has propagated, verify that the domain opens the City School application.
Step 15 — Enable HTTPS
In the App Service, configure your custom domain with an SSL/TLS certificate.
Use HTTPS for the production City School installation.
The final application URL should use:
https://
rather than:
http://
Step 16 — Test City School
Open the App Service URL or your custom domain.
Verify that:
- The City School home page loads
- Database connectivity works
- Login works
- Static assets load correctly
- File uploads work
- Application routes work correctly
- HTTPS is active
- No sensitive application files are publicly accessible
City School Environment Configuration
A typical production configuration will contain values similar to:
APP_ENV=production
APP_DEBUG=false
DB_CONNECTION=mysql
DB_HOST=YOUR_MYSQL_SERVER
DB_PORT=3306
DB_DATABASE=cityschool
DB_USERNAME=YOUR_MYSQL_USERNAME
DB_PASSWORD=YOUR_MYSQL_PASSWORD
Keep all credentials private and store them in Azure App Service Environment variables rather than committing them to your source repository.