问题
We have a PHP (Laravel) app hosted in microsoft web app service using debian 9 and apache2. We were able to make the app work by cloning our code in /var/www/html folder. However, since we are using laravel the document root should be in /var/www/html/public instead otherwise many of the features will not work properly.
We tried changing the conf file in /etc/apache2/sites-enabled/000-default.conf and reloaded the configuration however, upon checking using apache2ctl -S
it's still using the old configuration.
As last resort, we ended up changing the /etc/apache2/apache2.conf directly and change the document root there. It worked. However, if we restart the server, Azure for some reason discards the changes and restores the default apache2.conf file.
Is there a proper way of setting the vhost configuration in Azure? i.e. in the Portal?
回答1:
Yes, the default PHP image for App Service uses Apache, and it doesn't let you customize the site root for your app. To work around this limitation, add an .htaccess file to your repository root with the following content:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^.*$ /public/$1 [NC,L,QSA]
If you would rather not use .htaccess rewrite, you can deploy your Laravel application with a custom Docker image instead -https://docs.microsoft.com/en-us/azure/app-service/containers/quickstart-docker-go
来源:https://stackoverflow.com/questions/56985799/microsoft-azure-web-app-how-to-update-apache-vhost-config