Hi Sam Montgamery,
Looking at your screenshots, I can see the exact issue and will provide you with a step-by-step solution.
From your screenshots, I can see:
- Your App Service is configured correctly - You have PHP 8.2 selected as the runtime
- Your Laravel files are deployed - I can see all the Laravel directories (app/, public/, vendor/, etc.) in your wwwroot folder
- The startup.sh file exists - It's listed in your directory
- But you're getting a 502 error - This is because your custom nginx.conf is conflicting with Azure's built-in web server
The problem is you're trying to change the Nginx setup, which isn't needed on Azure App Service.
Please follow the solution step by step to fix the issue.
Step 1: Remove the custom nginx.conf override
Your current startup.sh is copying a custom nginx.conf, which is causing the conflict. We need to change this approach.
Delete or rename your current nginx.conf
file from the root directory, as Azure App Service doesn't use nginx with PHP-FPM sockets the way you've configured it.
Step 2: Update your startup.sh file
Replace the content of your startup.sh
file with this:
#!/bin/bash
cd /home/site/wwwroot
# Install dependencies
composer install --no-dev --optimize-autoloader
# Set proper permissions
chmod -R 755 storage bootstrap/cache
# Clear and cache configurations
php artisan config:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Create storage link if it doesn't exist
php artisan storage:link
Step 3: Configure document root for Laravel
Since Laravel needs the /public
folder as the document root, you need to add this configuration:
- Go to your App Service Configuration
- Click on Path mappings tab
- Add a new Virtual Application:
- Virtual path:
/
- Physical path:
site\wwwroot\public
- Check Application
- Virtual path:
Step 4: Set environment variables
In your App Service Configuration → Application settings, add your Laravel environment variables:
-
APP_ENV
=production
-
APP_DEBUG
=false
-
APP_KEY
= (your Laravel app key) - Add your database and other environment variables
Step 5: Ensure your .env file is properly set
Make sure your .env
file in the root directory has the correct production settings.
Azure App Service uses Apache (not Nginx) for PHP apps, so you can’t change Laravel’s root folder using Nginx settings. Instead, use path mappings to point to the /public
folder. The startup command should only run Composer and Laravel setup commands, not change the server settings.
Laravel Deployment Documentation
Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.
Let me know if you have any further Queries.