azure php配置文件,配置 PHP 应用 - Azure App Service | Microsoft Docs

孔宇
2023-12-01

您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

为 Azure 应用服务配置 PHP 应用Configure a PHP app for Azure App Service

06/02/2020

本文内容

本指南介绍了如何在 Azure 应用服务中配置 PHP Web 应用、移动后端和 API 应用。This guide shows you how to configure your PHP web apps, mobile back ends, and API apps in Azure App Service.

本指南为在应用服务中部署应用的 PHP 开发人员提供了重要概念和说明。This guide provides key concepts and instructions for PHP developers who deploy apps to App Service. 若从未使用过 Azure 应用服务,则首先应按照 PHP 快速入门以及将 PHP 与 MySQL 配合使用教程进行操作。If you've never used Azure App Service, follow the PHP quickstart and PHP with MySQL tutorial first.

显示 PHP 版本Show PHP version

要显示当前的 PHP 版本,请在 Cloud Shell 中运行以下命令:To show the current PHP version, run the following command in the Cloud Shell:

az webapp config show --resource-group --name --query phpVersion

要显示所有受支持的 PHP 版本,请在 Cloud Shell 中运行以下命令:To show all supported PHP versions, run the following command in the Cloud Shell:

az webapp list-runtimes | grep php

要显示当前的 PHP 版本,请在 Cloud Shell 中运行以下命令:To show the current PHP version, run the following command in the Cloud Shell:

az webapp config show --resource-group --name --query linuxFxVersion

要显示所有受支持的 PHP 版本,请在 Cloud Shell 中运行以下命令:To show all supported PHP versions, run the following command in the Cloud Shell:

az webapp list-runtimes --linux | grep PHP

设置 PHP 版本Set PHP version

在 Cloud Shell 中运行以下命令,将 PHP 版本设置为7.4:Run the following command in the Cloud Shell to set the PHP version to 7.4:

az webapp config set --name --resource-group --php-version 7.4

在 Cloud Shell 中运行以下命令,将 PHP 版本设置为 7.2:Run the following command in the Cloud Shell to set the PHP version to 7.2:

az webapp config set --name --resource-group --linux-fx-version "PHP|7.2"

运行编辑器Run Composer

如果你希望应用服务在部署时运行编辑器,最简单的方式是在你的存储库中包括编辑器。If you want App Service to run Composer at deployment time, the easiest way is to include the Composer in your repository.

在本地终端窗口中,将目录更改为你的存储库根目录,并按照下载编辑器中的说明将 composer.phar 下载到目录根目录。From a local terminal window, change directory to your repository root, and follow the instructions at download Composer to download composer.phar to the directory root.

运行以下命令(需要安装 npm):Run the following commands (you need npm installed):

npm install kuduscript -g

kuduscript --node --scriptType bash --suppressPrompt

你的存储库根目录中现在有两个额外的文件:.deployment 和 deploy.sh。Your repository root now has two additional files: .deployment and deploy.sh.

打开 deploy.sh 并找到 Deployment 节,该节如下所示:Open deploy.sh and find the Deployment section, which looks like this:

##################################################################################################################################

# Deployment

# ----------

在 Deployment 节的末尾添加运行必需工具所需的代码节:Add the code section you need to run the required tool at the end of the Deployment section:

# 4. Use composer

echo "$DEPLOYMENT_TARGET"

if [ -e "$DEPLOYMENT_TARGET/composer.json" ]; then

echo "Found composer.json"

pushd "$DEPLOYMENT_TARGET"

php composer.phar install $COMPOSER_ARGS

exitWithMessageOnError "Composer install failed"

popd

fi

提交所有更改,并在启用了生成自动化的情况下使用 Git 或 Zip 部署来部署你的代码。Commit all your changes and deploy your code using Git, or Zip deploy with build automation enabled. 编辑器现在应作为部署自动化的一部分运行。Composer should now be running as part of deployment automation.

运行 Grunt/Bower/GulpRun Grunt/Bower/Gulp

如果你希望应用服务在部署时运行常用的自动化工具(例如 Grunt、Bower 或 Gulp),则你需要提供自定义部署脚本。If you want App Service to run popular automation tools at deployment time, such as Grunt, Bower, or Gulp, you need to supply a custom deployment script. 当你在启用了生成自动化的情况下通过 Git 或 Zip 部署进行部署时,应用服务会运行此脚本。App Service runs this script when you deploy with Git, or with Zip deployment with build automation enabled.

若要使你的存储库能够运行这些工具,需要将它们添加到 package.json 中的依赖项。To enable your repository to run these tools, you need to add them to the dependencies in package.json. 例如:For example:

"dependencies": {

"bower": "^1.7.9",

"grunt": "^1.0.1",

"gulp": "^3.9.1",

...

}

在本地终端窗口中,将目录更改到你的存储库根目录,并运行以下命令(你需要安装 npm):From a local terminal window, change directory to your repository root and run the following commands (you need npm installed):

npm install kuduscript -g

kuduscript --node --scriptType bash --suppressPrompt

你的存储库根目录中现在有两个额外的文件:.deployment 和 deploy.sh。Your repository root now has two additional files: .deployment and deploy.sh.

打开 deploy.sh 并找到 Deployment 节,该节如下所示:Open deploy.sh and find the Deployment section, which looks like this:

##################################################################################################################################

# Deployment

# ----------

该节在末尾处运行 npm install --production。This section ends with running npm install --production. 在 Deployment 节的末尾添加运行必需工具所需的代码节:Add the code section you need to run the required tool at the end of the Deployment section:

请参阅 MEAN.js 示例中的示例,其中的部署脚本也运行自定义 npm install 命令。See an example in the MEAN.js sample, where the deployment script also runs a custom npm install command.

BowerBower

此代码片段运行 bower install。This snippet runs bower install.

if [ -e "$DEPLOYMENT_TARGET/bower.json" ]; then

cd "$DEPLOYMENT_TARGET"

eval ./node_modules/.bin/bower install

exitWithMessageOnError "bower failed"

cd - > /dev/null

fi

GulpGulp

此代码片段运行 gulp imagemin。This snippet runs gulp imagemin.

if [ -e "$DEPLOYMENT_TARGET/gulpfile.js" ]; then

cd "$DEPLOYMENT_TARGET"

eval ./node_modules/.bin/gulp imagemin

exitWithMessageOnError "gulp failed"

cd - > /dev/null

fi

GruntGrunt

此代码片段运行 grunt。This snippet runs grunt.

if [ -e "$DEPLOYMENT_TARGET/Gruntfile.js" ]; then

cd "$DEPLOYMENT_TARGET"

eval ./node_modules/.bin/grunt

exitWithMessageOnError "Grunt failed"

cd - > /dev/null

fi

自定义生成自动化Customize build automation

如果在启用生成自动化的情况下使用 Git 或 zip 包部署应用,应用服务生成自动化将按以下顺序完成各个步骤:If you deploy your app using Git or zip packages with build automation turned on, the App Service build automation steps through the following sequence:

运行 PRE_BUILD_SCRIPT_PATH 指定的自定义脚本。Run custom script if specified by PRE_BUILD_SCRIPT_PATH.

运行 php composer.phar install。Run php composer.phar install.

运行 POST_BUILD_SCRIPT_PATH 指定的自定义脚本。Run custom script if specified by POST_BUILD_SCRIPT_PATH.

PRE_BUILD_COMMAND 和 POST_BUILD_COMMAND 是默认为空的环境变量。PRE_BUILD_COMMAND and POST_BUILD_COMMAND are environment variables that are empty by default. 若要运行生成前命令,请定义 PRE_BUILD_COMMAND。To run pre-build commands, define PRE_BUILD_COMMAND. 若要运行生成后命令,请定义 POST_BUILD_COMMAND。To run post-build commands, define POST_BUILD_COMMAND.

以下示例在一系列命令中指定两个以逗号分隔的变量。The following example specifies the two variables to a series of commands, separated by commas.

az webapp config appsettings set --name --resource-group --settings PRE_BUILD_COMMAND="echo foo, scripts/prebuild.sh"

az webapp config appsettings set --name --resource-group --settings POST_BUILD_COMMAND="echo foo, scripts/postbuild.sh"

有关用于自定义生成自动化的其他环境变量,请参阅 Oryx 配置。For additional environment variables to customize build automation, see Oryx configuration.

有关应用服务如何在 Linux 中运行和构建 PHP 应用的详细信息,请参阅 Oryx 文档:如何检测和构建 PHP 应用。For more information on how App Service runs and builds PHP apps in Linux, see Oryx documentation: How PHP apps are detected and built.

自定义启动Customize start-up

默认情况下,内置 PHP 容器运行 Apache 服务器。By default, the built-in PHP container runs the Apache server. 启动时,它会运行 apache2ctl -D FOREGROUND"。At start-up, it runs apache2ctl -D FOREGROUND". 如有需要,可在启动时运行其他命令,方法是在 Cloud Shell 中运行以下命令:If you like, you can run a different command at start-up, by running the following command in the Cloud Shell:

az webapp config set --resource-group --name --startup-file ""

访问环境变量Access environment variables

在应用服务中,可以在应用代码外部设置应用设置。In App Service, you can set app settings outside of your app code. 然后,可以使用标准的 getenv() 模式访问这些设置。Then you can access them using the standard getenv() pattern. 例如,若要访问名为 DB_HOST 的应用设置,请使用以下代码:For example, to access an app setting called DB_HOST, use the following code:

getenv("DB_HOST")

更改站点根路径Change site root

所选的 Web 框架可能使用子目录作为站点根路径。The web framework of your choice may use a subdirectory as the site root. 例如,Laravel 使用 public/ 子目录作为站点根路径。For example, Laravel, uses the public/ subdirectory as the site root.

若要自定义站点根路径,请使用 az resource update 命令设置应用的虚拟应用程序路径。To customize the site root, set the virtual application path for the app by using the az resource update command. 下面的示例将站点根路径设置为存储库中的 public/ 子目录。The following example sets the site root to the public/ subdirectory in your repository.

az resource update --name web --resource-group --namespace Microsoft.Web --resource-type config --parent sites/ --set properties.virtualApplications[0].physicalPath="site\wwwroot\public" --api-version 2015-06-01

默认情况下,Azure 应用服务将根虚拟应用程序路径 (/) 指向已部署的应用程序的文件的根目录 (sites\wwwroot)。By default, Azure App Service points the root virtual application path (/) to the root directory of the deployed application files (sites\wwwroot).

所选的 Web 框架可能使用子目录作为站点根路径。The web framework of your choice may use a subdirectory as the site root. 例如,Laravel 使用 public/ 子目录作为站点根路径。For example, Laravel, uses the public/ subdirectory as the site root.

应用服务的默认 PHP 映像使用 Apache,不允许为应用自定义站点根路径。The default PHP image for App Service uses Apache, and it doesn't let you customize the site root for your app. 若要避开此限制,请将 .htaccess 文件添加到存储库根路径,并包含以下内容:To work around this limitation, add an .htaccess file to your repository root with the following content:

RewriteEngine on

RewriteCond %{REQUEST_URI} ^(.*)

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 会话Detect HTTPS session

在应用服务中,SSL 终止在网络负载均衡器上发生,因此,所有 HTTPS 请求将以未加密的 HTTP 请求形式访问你的应用。In App Service, SSL termination happens at the network load balancers, so all HTTPS requests reach your app as unencrypted HTTP requests. 如果应用逻辑需要检查用户请求是否已加密,可以检查 X-Forwarded-Proto 标头。If your app logic needs to check if the user requests are encrypted or not, inspect the X-Forwarded-Proto header.

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {

// Do something when HTTPS is used

}

使用常用 Web 框架可以访问采用标准应用模式的 X-Forwarded-* 信息。Popular web frameworks let you access the X-Forwarded-* information in your standard app pattern. 在 CodeIgniter 中,is_https() 默认检查 X_FORWARDED_PROTO 的值。In CodeIgniter, the is_https() checks the value of X_FORWARDED_PROTO by default.

自定义 php.ini 设置Customize php.ini settings

如果需要对 PHP 安装进行更改,则可以按照以下步骤更改任何 php.ini 指令。If you need to make changes to your PHP installation, you can change any of the php.ini directives by following these steps.

备注

查看 PHP 版本和当前 php.ini 配置的最佳方法是在应用中调用 phpinfo()。The best way to see the PHP version and the current php.ini configuration is to call phpinfo() in your app.

自定义非 PHP_INI_SYSTEM 指令Customize-non-PHP_INI_SYSTEM directives

若要自定义 PHP_INI_USER、PHP_INI_PERDIR 和 PHP_INI_ALL 指令(请参阅 php.ini 指令),请将 .user.ini 文件添加到应用的根目录中。To customize PHP_INI_USER, PHP_INI_PERDIR, and PHP_INI_ALL directives (see php.ini directives), add a .user.ini file to the root directory of your app.

使用会在 php.ini 文件中使用的语法,将配置设置添加到 .user.ini 文件。Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini file. 例如,如果希望启用 display_errors 设置,并将 upload_max_filesize 设置设为 10 分钟,则 .user.ini 文件应包含以下文本:For example, if you wanted to turn on the display_errors setting and set upload_max_filesize setting to 10M, your .user.ini file would contain this text:

; Example Settings

display_errors=On

upload_max_filesize=10M

; Write errors to d:\home\LogFiles\php_errors.log

; log_errors=On

通过更改重新部署应用,然后重启该应用。Redeploy your app with the changes and restart it.

除了使用 .user.ini 文件之外,还可以在应用中使用 ini_set() 来自定义这些非 PHP_INI_SYSTEM 指令。As an alternative to using a .user.ini file, you can use ini_set() in your app to customize these non-PHP_INI_SYSTEM directives.

要自定义 PHP_INI_USER、PHP_INI_PERDIR 和 PHP_INI_ALL 指令(请参阅 php.ini 指令),请将 .htaccess 文件添加到应用的根目录中。To customize PHP_INI_USER, PHP_INI_PERDIR, and PHP_INI_ALL directives (see php.ini directives), add an .htaccess file to the root directory of your app.

在 .htaccess 文件中,请使用 php_value 语法添加指令。In the .htaccess file, add the directives using the php_value syntax. 例如:For example:

php_value upload_max_filesize 1000M

php_value post_max_size 2000M

php_value memory_limit 3000M

php_value max_execution_time 180

php_value max_input_time 180

php_value display_errors On

php_value upload_max_filesize 10M

通过更改重新部署应用,然后重启该应用。Redeploy your app with the changes and restart it. 如果使用 Kudu(例如,使用 Git)部署应用,则该应用会在部署后自动重启。If you deploy it with Kudu (for example, using Git), it's automatically restarted after deployment.

作为使用 .htaccess 的替代方法,可以在应用中使用 ini_set() 来自定义这些非 PHP_INI_SYSTEM 指令。As an alternative to using .htaccess, you can use ini_set() in your app to customize these non-PHP_INI_SYSTEM directives.

自定义 PHP_INI_SYSTEM 指令Customize PHP_INI_SYSTEM directives

不能使用 .htaccess 方法自定义 PHP_INI_SYSTEM 指令(请参阅 php.ini 指令)。To customize PHP_INI_SYSTEM directives (see php.ini directives), you can't use the .htaccess approach. 应用服务使用 PHP_INI_SCAN_DIR 应用设置提供了一种单独的机制。App Service provides a separate mechanism using the PHP_INI_SCAN_DIR app setting.

首先,在 Cloud Shell 中运行以下命令,以添加名为 PHP_INI_SCAN_DIR 的应用设置:First, run the following command in the Cloud Shell to add an app setting called PHP_INI_SCAN_DIR:

az webapp config appsettings set --name --resource-group --settings PHP_INI_SCAN_DIR="d:\home\site\ini"

导航到 Kudu 控制台 (https://.scm.azurewebsites.net/DebugConsole),然后导航到 d:\home\site。Navigate to the Kudu console (https://.scm.azurewebsites.net/DebugConsole) and navigate to d:\home\site.

在 d:\home\site 中创建名为 ini 的目录,然后使用要自定义的指令在 d:\home\site\ini 目录中创建 .ini 文件(例如 settings.ini) 。Create a directory in d:\home\site called ini, then create an .ini file in the d:\home\site\ini directory (for example, settings.ini) with the directives you want to customize. 使用将在 php.ini 文件中使用的相同语法。Use the same syntax you would use in a php.ini file.

例如,要更改 expose_php 的值,请运行以下命令:For example, to change the value of expose_php run the following commands:

cd /home/site

mkdir ini

echo "expose_php = Off" >> ini/setting.ini

需要重启应用才能使更改生效。For the changes to take effect, restart the app.

不能使用 .htaccess 方法自定义 PHP_INI_SYSTEM 指令(请参阅 php.ini 指令)。To customize PHP_INI_SYSTEM directives (see php.ini directives), you can't use the .htaccess approach. 应用服务使用 PHP_INI_SCAN_DIR 应用设置提供了一种单独的机制。App Service provides a separate mechanism using the PHP_INI_SCAN_DIR app setting.

首先,在 Cloud Shell 中运行以下命令,以添加名为 PHP_INI_SCAN_DIR 的应用设置:First, run the following command in the Cloud Shell to add an app setting called PHP_INI_SCAN_DIR:

az webapp config appsettings set --name --resource-group --settings PHP_INI_SCAN_DIR="/usr/local/etc/php/conf.d:/home/site/ini"

/usr/local/etc/php/conf.d 是 php.ini 所在的默认目录。/usr/local/etc/php/conf.d is the default directory where php.ini exists. /home/site/ini 是自定义目录,你将在其中添加自定义 .ini 文件。/home/site/ini is the custom directory in which you'll add a custom .ini file. 使用 : 分隔值。You separate the values with a :.

使用 Linux 容器导航到 Web SSH 会话 (https://.scm.azurewebsites.net/webssh/host)。Navigate to the web SSH session with your Linux container (https://.scm.azurewebsites.net/webssh/host).

在 /home/site 中创建名为 ini 的目录,然后使用要自定义的指令在 /home/site/ini 目录中创建 .ini 文件(例如 settings.ini) 。Create a directory in /home/site called ini, then create an .ini file in the /home/site/ini directory (for example, settings.ini) with the directives you want to customize. 使用将在 php.ini 文件中使用的相同语法。Use the same syntax you would use in a php.ini file.

提示

在应用服务中的内置 Linux 容器中,/home 用作持久性共享存储。In the built-in Linux containers in App Service, /home is used as persisted shared storage.

例如,要更改 expose_php 的值,请运行以下命令:For example, to change the value of expose_php run the following commands:

cd /home/site

mkdir ini

echo "expose_php = Off" >> ini/setting.ini

需要重启应用才能使更改生效。For the changes to take effect, restart the app.

启用 PHP 扩展Enable PHP extensions

内置 PHP 安装包含最常用的扩展。The built-in PHP installations contain the most commonly used extensions. 可以按照与自定义 php.ini 指令相同的方式来启用其他扩展。You can enable additional extensions in the same way that you customize php.ini directives.

备注

查看 PHP 版本和当前 php.ini 配置的最佳方法是在应用中调用 phpinfo()。The best way to see the PHP version and the current php.ini configuration is to call phpinfo() in your app.

若要启用其他扩展,请执行下列步骤:To enable additional extensions, by following these steps:

将 bin 目录添加到应用的根目录,并将 .dll 扩展文件放入 (例如 mongodb.dll) 。Add a bin directory to the root directory of your app and put the .dll extension files in it (for example, mongodb.dll). 确保扩展与 Azure 中的 PHP 版本兼容,并且与 VC9 和非线程安全 (nts) 兼容。Make sure that the extensions are compatible with the PHP version in Azure and are VC9 and non-thread-safe (nts) compatible.

部署所做的更改。Deploy your changes.

Follow the steps in Customize PHP_INI_SYSTEM directives, add the extensions into the custom .ini file with the extension or zend_extension directives.

extension=d:\home\site\wwwroot\bin\mongodb.dll

zend_extension=d:\home\site\wwwroot\bin\xdebug.dll

需要重启应用才能使更改生效。For the changes to take effect, restart the app.

内置 PHP 安装包含最常用的扩展。The built-in PHP installations contain the most commonly used extensions. 可以按照与自定义 php.ini 指令相同的方式来启用其他扩展。You can enable additional extensions in the same way that you customize php.ini directives.

备注

查看 PHP 版本和当前 php.ini 配置的最佳方法是在应用中调用 phpinfo()。The best way to see the PHP version and the current php.ini configuration is to call phpinfo() in your app.

若要启用其他扩展,请执行下列步骤:To enable additional extensions, by following these steps:

在应用的根目录中添加 bin 目录,并将 .so 扩展文件放入其中(例如 mongodb.so)。Add a bin directory to the root directory of your app and put the .so extension files in it (for example, mongodb.so). 确保扩展与 Azure 中的 PHP 版本兼容,并且与 VC9 和非线程安全 (nts) 兼容。Make sure that the extensions are compatible with the PHP version in Azure and are VC9 and non-thread-safe (nts) compatible.

部署所做的更改。Deploy your changes.

Follow the steps in Customize PHP_INI_SYSTEM directives, add the extensions into the custom .ini file with the extension or zend_extension directives.

extension=/home/site/wwwroot/bin/mongodb.so

zend_extension=/home/site/wwwroot/bin/xdebug.so

需要重启应用才能使更改生效。For the changes to take effect, restart the app.

访问诊断日志Access diagnostic logs

使用标准 error_log() 实用工具使诊断日志显示在 Azure 应用服务中。Use the standard error_log() utility to make your diagnostic logs to show up in Azure App Service.

若要在应用服务中从应用程序代码内部访问生成的控制台日志,请在 Cloud Shell 中运行以下命令,打开诊断日志记录:To access the console logs generated from inside your application code in App Service, turn on diagnostics logging by running the following command in the Cloud Shell:

az webapp log config --resource-group --name --application-logging true --level Verbose

--level 的可能值为:Error、Warning、Info 和 Verbose。Possible values for --level are: Error, Warning, Info, and Verbose. 每个后续级别包括上一个级别。Each subsequent level includes the previous level. 例如:Error 仅包含错误消息,Verbose 则包含所有消息。For example: Error includes only error messages, and Verbose includes all messages.

启用诊断日志记录功能以后,请运行以下命令来查看日志流:Once diagnostic logging is turned on, run the following command to see the log stream:

az webapp log tail --resource-group --name

如果没有立即看到控制台日志,请在 30 秒后重新查看。If you don't see console logs immediately, check again in 30 seconds.

备注

也可通过浏览器在 https://.scm.azurewebsites.net/api/logs/docker 中检查日志文件。You can also inspect the log files from the browser at https://.scm.azurewebsites.net/api/logs/docker.

若要随时停止日志流式处理,请键入 Ctrl+C。To stop log streaming at any time, type Ctrl+C.

可以访问在容器中生成的控制台日志。You can access the console logs generated from inside the container.

首先,请运行以下命令,以便启用容器日志记录功能:First, turn on container logging by running the following command:

az webapp log config --name --resource-group --docker-container-logging filesystem

将 和 替换为适合 Web 应用的名称。Replace and with the names appropriate for your web app.

启用容器日志记录功能以后,请运行以下命令来查看日志流:Once container logging is turned on, run the following command to see the log stream:

az webapp log tail --name --resource-group

如果没有立即看到控制台日志,请在 30 秒后重新查看。If you don't see console logs immediately, check again in 30 seconds.

若要随时停止日志流式处理,可键入 Ctrl+C 。To stop log streaming at any time, type Ctrl+C .

也可通过浏览器在 https://.scm.azurewebsites.net/api/logs/docker 中检查日志文件。You can also inspect the log files in a browser at https://.scm.azurewebsites.net/api/logs/docker.

疑难解答Troubleshooting

如果运行中的 PHP 应用在应用服务中的行为不同或有错误,请尝试执行以下操作:When a working PHP app behaves differently in App Service or has errors, try the following:

在生产模式下,在本地测试应用。Test the app locally in production mode. 应用服务在生产模式下运行你的应用,因此你需要确保项目在生产模式下按预期在本地运行。App Service runs your app in production mode, so you need to make sure that your project works as expected in production mode locally. 例如:For example:

根据 composer.json,可以为生产模式安装不同的包(require 与 require-dev)。Depending on your composer.json, different packages may be installed for production mode (require vs. require-dev).

某些 Web 框架可以在生产模式下通过各种方式部署静态文件。Certain web frameworks may deploy static files differently in production mode.

在生产模式下运行时,某些 Web 框架可能会使用自定义的启动脚本。Certain web frameworks may use custom startup scripts when running in production mode.

在调试模式下,在应用服务中运行应用。Run your app in App Service in debug mode. 例如,在 Laravel 中,可以通过将 APP_DEBUG 应用设置设置为 true以将应用配置为在生产环境中输出调试消息。For example, in Laravel, you can configure your app to output debug messages in production by setting the APP_DEBUG app setting to true.

日志中的 robots933456robots933456 in logs

你可能会在容器日志中看到以下消息:You may see the following message in the container logs:

2019-04-08T14:07:56.641002476Z "-" - - [08/Apr/2019:14:07:56 +0000] "GET /robots933456.txt HTTP/1.1" 404 415 "-" "-"

可以放心忽略此消息。You can safely ignore this message. /robots933456.txt 是一个虚拟 URL 路径,应用服务使用它来检查容器能否为请求提供服务。/robots933456.txt is a dummy URL path that App Service uses to check if the container is capable of serving requests. 404 响应只是指示该路径不存在,但它让应用服务知道容器处于正常状态并已准备就绪,可以响应请求。A 404 response simply indicates that the path doesn't exist, but it lets App Service know that the container is healthy and ready to respond to requests.

后续步骤Next steps

 类似资料: