1、安装配置问题
iis处理程序模块
php.ini:
date.timezone="Asia/Shanghai"
extension_dir="C:\php-7.4.33-nts-Win32-vc15-x64\ext"
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_pdo_mysql.dll
extension=php_com_dotnet.dll
2、winserver 2012安装了php 之后,再安装 微软VC++运行库合集_2023.04.24.exe ,可以跑.net 4程序了,但iis 下php ,远程php 提示404.3 NOT FOUND错误
打开 管理员 CMD,执行以下命令检查 PHP 是否正确映:
%windir%\system32\inetsrv\appcmd list config /section:system.webServer/handlers
如果 *.php
没有映射到 FastCgiModule
,或者指向的路径不是 d:\php7433\php-cgi.exe
,那么需要手动添加:
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+"[name='PHP-FastCGI', path='*.php', verb='GET,HEAD,POST', modules='FastCgiModule', scriptProcessor='d:\php7433\php-cgi.exe', resourceType='File']"
然后 重启 IIS:
iisreset
web.config文件
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" /> </staticContent> <defaultDocument> <files> <clear /> <add value="index.php" /> <add value="index.asp" /> </files> </defaultDocument> <httpErrors errorMode="Detailed" /> <handlers> <remove name="PHP-FastCGI" /> <add name="PHP-FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="d:\php7433\php-cgi.exe" resourceType="File" /> </handlers> </system.webServer> </configuration>
2、解决浏览器中 php 404错误以后,开始测试 call dotnet 程序:
方案
test3.php
<?php $stack = new DOTNET("mscorlib", "System.Collections.Stack"); $stack->Push(".Net"); $stack->Push("Hello "); echo $stack->Pop() . $stack->Pop(); ?>
http://192.168.9.139:8090/test3.php 可得正常结果。
test2.php
<?php $sem="c:\\test1\\classLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e64c93b3fd88cb63"; $class = "CC1.AA"; // its the namespace and the class. $dotnet = new DotNet($sem, $class); echo $dotnet->MyMethod("World"); ?>
这是一个c# 4.0的 dll ,输出x86, 还anycpu都不可以
conole.php:
<?php $output = shell_exec('ConsoleApp1.exe World222'); echo $output; ?>
也不可以。
中间尝试将classLibrary1.dll 使用regasm 注册,也不可以。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步