php 如何在 Windows 计算机上的 Apache 中设置读/写权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9959458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 07:59:17  来源:igfitidea点击:

How to set read/write permissions in Apache on a Windows computer

phpapachesecurity

提问by Mike_Laird

I am building a web page with Apache2.2, PHP5.2.2 on a Windows XP computer in a localhost configuration. I'm developing app/pages/submitProcessor.php to validate photo uploads from users. It validates file existance, size, mime type, drops unwanted characters, assigns a new file name, and uses move_uploaded_file() to store the file in app/uploads. I read in PHP - Question about uploading & uploaded image filethat this photo storage file should be write only from app/pages/submitProcessor.php and it would be nice if it were read only from code within app/pages.

我正在本地主机配置的 Windows XP 计算机上使用 Apache2.2、PHP5.2.2 构建网页。我正在开发 app/pages/submitProcessor.php 来验证用户上传的照片。它验证文件的存在、大小、mime 类型、删除不需要的字符、分配新的文件名,并使用 move_uploaded_file() 将文件存储在 app/uploads 中。我在PHP - 关于上传和上传图像文件的问题中读到,这个照片存储文件应该只从 app/pages/submitProcessor.php 写入,如果它只能从 app/pages 中的代码读取,那就太好了。

I've read a lot of info, and being pretty new to this, I still don't understand how to set read/write permissions in Windows XP in something resembling my configuration. I'm completely confused by 777, 775, 755, php.ini vs httpd.config and linux vs Windows. I'm also not comfortable with command line stuff, and would prefer to edit the appropriate file, if that is possible. How do I configure Apache so any file in app/uploads will not be executable, will write only from app/pages/submitProcessor.php, and read from app/pages/display or others in app/pages . . . or at least I'd like to get close to that. Not executable in the app/upload directory is pretty important to me.

我已经阅读了很多信息,并且对此很陌生,我仍然不明白如何在类似于我的配置的东西中设置 Windows XP 中的读/写权限。我对 777、775、755、php.ini 与 httpd.config 以及 linux 与 Windows 完全感到困惑。我也不喜欢命令行的东西,如果可能的话,我更愿意编辑适当的文件。如何配置 Apache 以使 app/uploads 中的任何文件都无法执行,只能从 app/pages/submitProcessor.php 写入,并从 app/pages/display 或 app/pages 中的其他文件读取。. . 或者至少我想接近那个。在 app/upload 目录中不可执行对我来说非常重要。

采纳答案by Mike_Laird

In Windows, access to directories/folders is set by right clicking the directory, and reading through the selections provided by the various tabs to set access and specific uses of the directory. Its not as fine-grained as CHMOD, but it was good enough for my purposes at the moment.

在 Windows 中,通过右键单击目录并阅读各种选项卡提供的选项来设置对目录/文件夹的访问权限,以设置目录的访问权限和特定用途。它不像 CHMOD 那样细粒度,但目前对于我的目的来说已经足够了。

回答by rightstuff

If you are running Apache as a Service (the default setup for stand-alone & WAMP Apache installations), then that Apache Service is running under Windows' LocalSystemaccount.

如果您正在运行 Apache 即服务(独立和 WAMP Apache 安装的默认设置),那么该 Apache 服务将在 WindowsLocalSystem帐户下运行。

This Windows account already has full read and write ('777') permissions on most local paths.

此 Windows 帐户已对大多数本地路径具有完全读取和写入 ('777') 权限。

So when you read instructions to chmod 777this, chmod 755that, etc, ... you can ignore those parts of the instructions. Apache already can read-from and writeout-to those directories (unless it's a UNC path of a networked drive).

所以当你阅读chmod 777这个、chmod 755那个等的说明时,你可以忽略这些部分的说明。Apache 已经可以读取和写入这些目录(除非它是网络驱动器的 UNC 路径)。

Setting File Permissions with chmod on Windows for Apache and PHP

在 Windows 上使用 chmod 为 Apache 和 PHP 设置文件权限

I'm not 100% positive if that was the account on Windows XP (it is on Vista and up), but the behavior was the same.

如果那是 Windows XP 上的帐户(在 Vista 及更高版本上),我不是 100% 肯定,但行为是相同的。