Dec 2, 2023
0
Level 3
How to fix 403 Forbidden error after deploying Laravel app to Azure App Service?
I have a simple Laravel app in Azure DevOps.
Below is my yml file for the CI logic and I can successfully create a release and deploy it to an Azure App Service. However, when I load the url I get a 403 Forbidden error.
If more info is needed please let me know. Thanks.
trigger:
- main
variables:
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Root folder under which your composer.json file is available.
rootFolder: $(System.DefaultWorkingDirectory)
stages:
- stage: Build
displayName: Build stage
variables:
phpVersion: '8.2'
jobs:
- job: BuildJob
pool:
vmImage: $(vmImageName)
steps:
- script: |
sudo update-alternatives --set php /usr/bin/php$(phpVersion)
sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
php -version
workingDirectory: $(rootFolder)
displayName: 'Use PHP version $(phpVersion)'
- script: composer install --no-interaction --prefer-dist
workingDirectory: $(rootFolder)
displayName: 'Composer install'
- script: |
cp .env.example .env
php artisan key:generate
php artisan config:clear
php artisan config:cache
workingDirectory: $(rootFolder)
displayName: 'Set Laravel Environment'
- script: php artisan test
displayName: 'Run tests with phpunit'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(rootFolder)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Upload package'
artifact: drop
Please or to participate in this conversation.