【应用服务 App Service】Azure App Service 中如何安装mcrypt - PHP
问题描述
Azure App Service (应用服务)如何安装PHP的扩展 mcrypt(mcrypt 是php里面重要的加密支持扩展库),同样改方法也适用于其他的扩展安装。在门户的配置项上添加PHP_EXTENSIONS,如有多个扩展使用逗号,分隔。
准备条件
- 创建App Service, Runtime stack 选择为PHP,如图
- 下载mcrypt插件,mcrypt 1.0.3 for Windows, 注意选择的版本需要与App Service中PHP的版本一致。如PHP 7.2 -- 7.2 Non Thread Safe (NTS) x86
注:选择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 extensions :https://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
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
· PowerShell开发游戏 · 打蜜蜂