繁体   English   中英

如何在没有公共端点的 azure 和 Laravel 8 和 PHP 8 中部署应用服务?

[英]How to Deploy an App Service in azure with Laravel 8 and PHP 8 without public endpoint?

我正在 azure 中使用 Laravel 8 和 PHP 8 部署应用程序服务,但我无法从 URL 中删除/public。

通常我们解决这个问题

  1. 将域定向到公用文件夹和公用文件夹中的 .htaccess/web.config 文件

  2. 将 .htaccess/web.config 文件放在根目录中

但在这里它不起作用。

我正在为未来的用户回答这个问题,因为我花了大约 7-8 个小时来修复它。

我从schaako.decristopherazureossd那里得到了帮助,并将它写在这里。

开通SSH

通过Azure Portal导航到您的App Service Development Tools section下,select SSH

默认站点配置

现有配置的副本并使用此命令将文件放在/home/site目录中

cp /etc/nginx/sites-available/default /home/site/default

现在编辑/home/site/default文件并更新,如laravel 文档服务器配置设置中所述

location / {
    index  index.php index.html index.htm hostingstart.html;
    try_files $uri $uri/ /index.php?$query_string;
}

自定义启动脚本

您现在需要创建自定义启动脚本并将文件另存为/home/site/startupscriptbymoon.sh

在上面的文件中添加以下命令

cp /home/site/default /etc/nginx/sites-available/default
service nginx reload

启动命令和测试

现在通过Azure Portal导航回您的App Service Settings section下,select Configuration ,然后是General Settings

Startup Command文本框中输入以下内容:

/home/site/startupscriptbymoon.sh

导航回您的应用程序并重新加载。 请享用!

我经历了同样的斗争,并在我的博客https://www.azurephp.dev/2021/09/php-8-on-azure-app-service/中记录了我的发现。

移动到 Linux 只有容器,从 Apache 到 Nginx 增加了我在文章中报告的一系列问题。 查看更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM