在IIS调试PHP的错误(因为它涉及到调用COM对象) [英] Debugging PHP error on IIS (as it relates to calling com objects)

查看:288
本文介绍了在IIS调试PHP的错误(因为它涉及到调用COM对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题涉及到另外一个问题,我说:

This question is related to another question I wrote:

使用DOTNET从PHP 麻烦。

Trouble using DOTNET from PHP.

我在那里用了 DOTNET()函数在PHP中调用DLL我写的。

Where I was using the DOTNET() function in PHP to call a DLL I had written.

我能得到它工作正常通过在命令行(与DLL的还是在PHP文件夹中)运行的php.exe使用example.php

I was able to get it working fine by running php.exe example.php from the command line (with the DLL's still in the PHP folder).

我感动的PHP文件到IIS 7的Web服务器文件夹在同一台机器(留在同一个PHP文件夹中的DLL),但我不断收到一个的 500内部服务出错的。

I moved the php file to an IIS 7 webserver folder on the same machine (leaving the DLLs in the same php folder), but I keep getting a 500 internal service error.

我已经检查了服务器日志(在 C:\ inetput \日志\ C:\ WINDOWS \ TEMP \ php53errors ),但似乎没有被有关错误原因的任何相关信息。我甚至试图改变的php.ini 设置,以获得更多的错误的反馈,但似乎并没有帮助。

I've checked the server logs (in c:\inetput\logs\ and in c:\windows\temp\php53errors) but there doesn't seem to be any relevant information about what caused the error. I even tried to change the php.ini settings to get more error feedback, but that doesn't seem to help.

我只能猜测,该问题可能与

I can only guess that the issue may be related to:

  1. 的PHP文件不具有适当的权限(我的DLL做一些文件读/写)
  2. 在PHP中无法找到的DLL

我得到的实际的错误是:

The actual error I get is:

FastCGI进程意外退出。

The FastCGI process exited unexpectedly.

在如何调试这个问题的任何想法?

Any idea on how to debug this problem?

推荐答案

这里的问题是几乎可以肯定有关文件的权限。

The problem here is almost certainly related to file permissions.

当您运行的php.exe 从运行作为自己的登录用户的命令行。当从IIS中运行PHP脚本,响应HTTP请求,php.exe的运行,为不同的用户。根据您的Windows版本可能是

When you run php.exe from the command line you run as your own logged-in user. When running a PHP script from IIS, in response to an http request, php.exe runs as a different user. Depending on your version of Windows it could be

  • IUSR_MACHINE - 在IIS6和前
  • IUSR 在IIS7及更高版本
  • IUSR_machine - on IIS6 and prior
  • IUSR on IIS7 and later

这些用户需要执行的PHP文件的权限。

These users need permissions on the php file to be executed.

阅读更多关于它

在IIS7的,后来我用一个命令行工具,称为的 icacls.exe 以设置目录或需要由IIS和进程读取文件的权限启动(就像是php.exe) 。这种安全的东西适用于所有的IIS应用程序:PHP,ASPNET,ASP经典,Python和等。

On IIS7 and later I use a command-line tool called icacls.exe to set the permissions on directories or files that need to be read by IIS and the processes it starts (like php.exe). This security stuff applies to all IIS applications: PHP, ASPNET, ASP-classic, Python, and so on.

IIS还需要能够读取静态文件,如热媒,.js文件,的CSS,.jpog,.png文件等。您可以设置相同的权限,所有的人:读取和执行。

IIS also needs to be able to read static files, like .htm, .js, .css, .jpog, .png files and so on. You can set the same permissions for all of them: Read and Execute.

您可以直接授予的权限给用户,这样的:

You can grant permissions directly to the user, like this:

 icacls.exe  YOUR-FILE-GOES-HERE  /grant "NT AUTHORITY\IUSR:(RX)"

您还可以授予权限到组,到IUSR所属,是这样的:

You can also grant permissions to the group, to which IUSR belongs, like this:

 icacls.exe YOUR-FILE-HERE  /grant "BUILTIN\IIS_IUSRS:(RX)"

在这两种情况下,你可能需要停止并设置文件级权限后,重新启动IIS。

In either case you may need to stop and restart IIS after setting file-level permissions.

如果您的.php脚本读取和写入其他文件或目录,那么同样的用户需要对这些文件和目录pernissions。如果您需要的.php脚本能够删除的文件,那么你可能想

If your .php script reads and writes other files or directories, then the same user needs pernissions on those other files and directories. If you need the .php script to be able to delete files, then you might want

 icacls.exe YOUR-FILE-HERE  /grant "BUILTIN\IIS_IUSRS:(F)"

...这完全授予权限,该文件。

...which grants full rights to the file.

您可以在整个目录授予权限,也指定在该目录中的在今后创建的所有文件的将继承目录上设置文件特定的权限。例如,设置文件的权限的目录,然后复制一堆文件进去,所有的文件,您可以通过父的权限。与OI和CI标志做到这一点(这些字母代表对象继承和容器继承)。

You can grant permissions on an entire directory, too, specifying that all files created in that directory in the future will inherit the file-specific permissions set on the directory. For example, set the file perms for the directory, then copy a bunch of files into it, and all the files get the permissions from the parent. Do this with the OI and CI flags (those initials stand for "object-inherit" and "container-inherit").

 icacls.exe DIRECTORY  /grant "BUILTIN\IIS_IUSRS:(OI)(CI)(RX)"
 copy FILE1 DIRECTORY
 copy FILE2 DIRECTORY
   ...

当我想在IIS中创建一个新的VDIR,允许运行PHP脚本,或ASPX或.J​​S(是的,ASP经典)或Python或什么的,我做这些步骤:

When I want to create a new vdir in IIS, to allow running PHP scripts, or ASPX or .JS (yes, ASP Classic) or Python or whatever, I do these steps:

appcmd.exe add app /site.name:"Default Web Site" /path:/vdirpath /physicalPath:c:\docroot
icacls.exe DIRECTORY  /grant "BUILTIN\IIS_IUSRS:(OI)(CI)(RX)"

然后我文件拖放到该目录中,他们得到适当的权限。

Then I drop files into the directory, and they get the proper permissions.

设置ACL(访问控制列表)上的目录将不会改变已经存在于目录中的文件的访问控制列表。如果你想对那些已经在目录中的文件设置权限,您需要使用icacls.exe特定的文件。 ICACLS接受通配符,它​​也有一个 /吨开关,递归。

Setting the ACL (access control list) on the directory will not change the ACL for the files that already exist in the directory. If you want to set permissions on the files that are already in the directory, you need to use icacls.exe on the particular files. icacls accepts wildcards, and it also has a /t switch that recurses.

这篇关于在IIS调试PHP的错误(因为它涉及到调用COM对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆