【应用服务 App Service】Azure App Service 中如何安装mcrypt - PHP

问题描述

Azure App Service (应用服务)如何安装PHP的扩展 mcrypt(mcrypt 是php里面重要的加密支持扩展库),同样改方法也适用于其他的扩展安装。在门户的配置项上添加PHP_EXTENSIONS,如有多个扩展使用逗号,分隔。

准备条件

  • 创建App Service, Runtime stack 选择为PHP,如图

 

注:选择Non Thread的原因是因为App Service的支持要求. https://docs.microsoft.com/en-us/azure/app-service/configure-language-php?pivots=platform-windows#enable-php-extensions

Enable PHP extensions

The best way to see the PHP version and the current php.ini configuration is to call phpinfo() in your app.

... ...

Add a bin directory to the root directory of your app and put the .dll extension files in it (for example, mongodb.dll). Make sure that the extensions are compatible with the PHP version in Azure and are VC9 and non-thread-safe (nts) compatible.

 

操作步骤

1)登录到Kudu站点,选择DebugConsole -> CMD。点击site和wwwroot文件夹后,进入wwwroot目录(两种方式登录Kudu。一:Azure App Service Overview -> Advanced Tools

-> Go。 二:在站点URL加上SCM访问。如:https://xxxxxx.scm.chinacloudsites.cn/)

2)在wwwroot目录中新建bin文件夹,并把php_mcrypt-1.0.3-7.2-nts-vc15-x86.zip压缩包中的内容解压后放入bin目录中(放入方式为 选中文件后直接拖拽到Kudu页面中bin文件夹区域

3)在wwwroot目录中新建info.php。文件内容包含phpinfo()函数的输出信息(点击文件夹旁边的加号创建新文件,然后点击文件左边的🖊按钮编辑文件内容

<?php

phpinfo();

phpinfo(INFO_MODULES);

?>

4)回到App Service 的配置页面 (Azure App Service Overview -> Configuration -> Application settings),添加参数PHP_EXTENSIONS,值为bin\php_mcrypt.dll

5)重启站点,访问info.php页面参看mcrypt插件信息,如:https://xxxxxx.chinacloudsites.cn/info.php

 

参考资料

Enable PHP extensionshttps://docs.microsoft.com/en-us/azure/app-service/configure-language-php?pivots=platform-windows#enable-php-extensions

 

mcrypt 1.0.3 for Windows : https://pecl.php.net/package/mcrypt/1.0.3/windows

 

 

posted @ 2020-10-10 16:56  路边两盏灯  阅读(215)  评论(0编辑  收藏  举报