PHP files does not execute in windows machine

时光总嘲笑我的痴心妄想 提交于 2019-12-10 19:26:57

问题


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..


回答1:


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.




回答2:


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

php -S localhost:8000 -t public



回答3:


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!




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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




回答8:


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




回答9:


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.




回答10:


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.



来源:https://stackoverflow.com/questions/8360842/php-files-does-not-execute-in-windows-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!