Microsoft Azure Web App-如何更新apache vhost配置? [英] Microsoft Azure Web App - How to update apache vhost config?

查看:56
本文介绍了Microsoft Azure Web App-如何更新apache vhost配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用debian 9和apache2在Microsoft Web应用程序服务中托管的PHP(Laravel)应用程序.通过克隆/var/www/html文件夹中的代码,我们能够使该应用程序正常工作.但是,由于我们使用的是laravel,因此文档根目录应位于/var/www/html/public中,否则许多功能将无法正常工作.

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.

我们尝试更改/etc/apache2/sites-enabled/000-default.conf中的conf文件并重新加载配置,但是,在使用 apache2ctl -S 检查后,它仍在使用旧配置.

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.

作为最后的选择,我们最终直接更改了/etc/apache2/apache2.conf并在那里更改了文档根目录.有效.但是,如果我们重新启动服务器,Azure出于某种原因会放弃更改并还原默认的apache2.conf文件.

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.

是否存在在Azure中设置虚拟主机配置的正确方法?即在门户网站中?

Is there a proper way of setting the vhost configuration in Azure? i.e. in the Portal?

推荐答案

是的,App Service的默认PHP映像使用Apache,并且不允许您自定义应用程序的站点根目录.要解决此限制,请将.htaccess文件添加到您的存储库根目录,其中包含以下内容:

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]

如果您不想使用.htaccess重写,则可以使用自定义Docker映像来部署Laravel应用程序--

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

这篇关于Microsoft Azure Web App-如何更新apache vhost配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆