PHP 文件无法在 Windows 机器上执行

发布于 2024-12-19 06:48:31 字数 311 浏览 1 评论 0原文

我在我的 mac osx 上用 PHP 创建了该应用程序。开发完成后,我将其压缩并转移到 Windows 7 机器上。当我尝试打开它时,出现此错误。

警告:未知:无法打开流:第 0 行未知的权限被拒绝

致命错误:未知:无法打开第 0 行未知中所需的“C:/wamp/www/app/index.php”(include_path='.;C:\php\pear')

上述错误表明,该错误是由于文件权限问题引起的,有什么可能的方法可以在 Windows 本身中修复此错误。

谢谢..

i created the application in PHP on my mac osx. and after the development i zipped and transferred to the windows 7 machine. and when i tried opening it i get this error.

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required 'C:/wamp/www/app/index.php' (include_path='.;C:\php\pear') in Unknown on line 0

the above error suggest, the error is caused because of the file permission issue, is there any possible way i can fix this error in windows itself.?

thank you..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

冰葑 2024-12-26 06:48:32

当需要文件时,代码中似乎出现了一些混乱:

C:/wamp/www/app/index.php

在 Windows 机器上不是有效路径,Windows 使用“\”作为目录分隔符,而 linux/unix/mac 使用“/”。

在 PHP 中从不硬编码目录斜杠,使用常量:

DIRECTORY_SEPARATOR

允许您的代码在任何平台上无缝运行。

It looks like something is messed up in your code when requiring a file:

C:/wamp/www/app/index.php

Is not a valid path on a windows machine, windows uses "\" for a directory separator while linux/unix/mac uses a "/".

In PHP never hard code directory slashes, use the constant:

DIRECTORY_SEPARATOR

To allow your code to run seamlessly on any platform.

晨曦÷微暖 2024-12-26 06:48:32

对于那些想知道我如何解决这个问题的人。

问题出在 index.php 文件的文件权限上,当我更改 index.php 文件的文件权限时,它起作用了。

For the people who wants to know how i solved this.

The issue was with the file permission of index.php file, when i changed the file permission for index.php it worked.

痴意少年 2024-12-26 06:48:31

我发现这是因为index.php文件设置了加密。

对于任何想要排除这种情况的人 - 右键单击​​ php 文件,选择“属性”,然后单击“高级”按钮,取消选中“加密内容以保护数据”复选框,然后单击“确定”。这对我有用,所以就把它放在那里。

I had this and found that it was because the index.php file was set with encryption.

For anyone that wants to rule it out - right click the php file, select 'properties' then click the 'advanced' button and uncheck the 'Encrypt contents to secure data' check box and click 'O.K'. This worked for me, so just putting it out there.

难如初 2024-12-26 06:48:31

在你的cmd中尝试使用以下命令运行你的项目

php -S localhost:8000 -t public

In your cmd try to run your project with the following command

php -S localhost:8000 -t public
池木 2024-12-26 06:48:31

对我来说,问题是请求的文件位于我的 OneDrive 文件夹中。我将 DocumentRoot 从 OneDrive 中移出,一切正常!

For me, the problem was that the requested file was in my OneDrive folder. I moved the DocumentRoot out of OneDrive and it all worked!

浮生未歇 2024-12-26 06:48:31

就我而言,index.php 适用于其他网站。对于有问题的网站,index.html 文件可以工作,但不能使用 index.php。它导致了像该线程的第一条消息一样的错误消息。

罪魁祸首是我网站 Windows 文件系统上网站目录路径中的斯堪的纳维亚“ä”。我将其更改为“a”并重新启动服务器。这解决了问题。

In my case index.php worked for other sites. To the site that had problems index.html file worked but not index.php. It caused the error message like in the first message of this thread.

The culprit was scandinavian 'ä' in the directory path of the site on Windows's file system of my site. I changed it to 'a' and restarted the server. That solved the problem.

江城子 2024-12-26 06:48:31

我在使用 UwAmp 时遇到了同样的问题。我解决了这个问题,将路径上的文件夹名称从 Formación 更改为 Formacion,删除重音符号,这似乎是一个问题。

I had the same problem with UwAmp. I solved it changing the name of a folder on my path, from Formación to Formacion, removing the accent mark, that seems to be a problem.

画尸师 2024-12-26 06:48:31

对我来说,这显然是由于别名文件夹位于与 C:/ 驱动器不同的驱动器中造成的。我将该文件夹移至 C:/ 驱动器,问题得到解决。

For me, this was apparently caused by having the aliased folder in a different drive to the C:/ drive. I moved the folder to C:/ drive and it rectified the problem.

孤独岁月 2024-12-26 06:48:31

您必须为 SYSTEM 组设置权限,而不仅仅是当前用户。属性->安全(或类似的东西),然后选择系统>编辑>允许完全控制>好的

you must set permissions for SYSTEM's group, not only for your current user. Properties -> security (or something like that), then select SYSTEM > Edit > Allow Full Control > OK

简单 2024-12-26 06:48:31

这听起来像是一个权限问题,您需要右键单击文档“属性”>“安全性 单击“每个人”或“系统”,具体取决于其 XP 或 win 7/Vista 编辑其权限以允许他们读取和执行。

参考单击此处

It sounds like a permissions problem you would need to right click on the document Properties > Security Click on everybody or SYSTEM depending on if its XP or win 7/Vista edit thier permissions to allow them to read and execute.

For Reference Click Here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文