I am Deploying an App Service in azure with Laravel 8 and PHP 8 but i am unable to remove /public from URL.
Generally we solve this problem with
Directing Domain to public folder and .htaccess/web.config file in public folder
placing an htaccess/web.config file in root
but here it is not working.
CodePudding user response:
I am answering this question for future users as i spent apprx 7-8 hours in fixing it.
I took help from schaako.de , cristopher and azureossd and writing it here.
Open SSH
Navigate to your App Service
via the Azure Portal
. Under the Development Tools section
, select SSH
.
Default site config
copy of the existing configuration and place the file inside the /home/site
directory using this commands
cp /etc/nginx/sites-available/default /home/site/default
Now edit the /home/site/default
file and update as described in laravel documentation Server Configuration settings
location / {
index index.php index.html index.htm hostingstart.html;
try_files $uri $uri/ /index.php?$query_string;
}
custom startup script
You will now need to create a custom startup script and save the file as /home/site/startupscriptbymoon.sh
Add following commands in above file
cp /home/site/default /etc/nginx/sites-available/default
service nginx reload
Startup Command and Test
Now navigate back to your App Service
via the Azure Portal
. Under the Settings section
, select Configuration
and then General Settings
.
In Startup Command
text box enter the following:
/home/site/startupscriptbymoon.sh
navigate back to your application and reload. enjoy!
CodePudding user response:
I went through the same struggle and blogged my findings at my blog https://www.azurephp.dev/2021/09/php-8-on-azure-app-service/.
The move to Linux only containers and from Apache to Nginx added a whole series of troubles which I reported in my article. Check it out for more details.