用户/权限问题和 PHP 单文件安装程序

发布于 2024-10-28 11:03:35 字数 612 浏览 7 评论 0原文

自从听说 PHP 中的 __HALT_COMPILER 以来,我一直在做一些实验单文件 PHP 安装程序(包含 Web 应用程序文件树压缩存档的脚本)。

生成一个包含存档以及解压存档和处理配置的逻辑的脚本似乎很容易。但权限/用户相关的问题似乎有点棘手。 PHP 进程很可能以 Web 服务器运行的任何用户身份运行(除了 suexec/CGI 情况),因此它可能没有权限写入它运行的任何目录。我想如果用户知道如何临时更改安装目标目录的权限,但单文件安装背后的部分想法是简化用户必须做的事情,所以我不太喜欢这个。但更重要的是,一旦安装完成,在我看来,文件和子目录将由网络服务器用户拥有,因此用户将无法管理它们(除非通过更多网络脚本)。

我考虑过尝试使用 susudo 来解决这个问题。但是,我不确定如何导航发出的 su/sudo 命令后的密码提示。据我了解,sudo 也可能仅限于一部分用户。

有没有一种好方法来创建 PHP 安装程序脚本来编写具有用户友好的所有权和权限的文件?

Since hearing about __HALT_COMPILER in PHP, I've been doing some experimentation with a single-file PHP installers (scripts containing a compressed archive of a filetree for a webapp).

It seems to be easy enough to generate a script that contains both the archive and the logic for unpacking it and taking care of configuration. But permissions/user related issues seem to be a bit more thorny. It's highly likely (except in suexec/CGI cases) the PHP process is running as whatever user the webserver runs as, and so it likely doesn't have permissions to write in whatever directory it's running in. I suppose this issue can be skirted if the user knows how to temporarily change the permissions of the directory targeted for the install, but part of the idea behind single-file installs is to simplify what the user has to do, so I don't like this much. More important, though, once the install is done, it seems to me the files and subdirectories are going to be owned by the webserver user, and they'll therefore be unmanageable by the user (except via more web scripts).

I've thought a little bit about trying to use su or sudo to fix this. However, I'm not sure how to navigate the password prompt that's going to follow an issued su/sudo command. It's my understanding sudo also may be limited to a subset of users.

Is there a good way to create PHP installer scripts which write files that have user-tinkering-friendly ownership and permissions?

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

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

发布评论

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

评论(1

墨落画卷 2024-11-04 11:03:36

是否有一个好方法来创建 PHP 安装程序脚本来编写具有用户友好的所有权和权限的文件?

我只见过使用一种方法成功完成此任务,这很可怕/有趣:FTP。 FTP 扩展 通常已启用,如果未启用, 您还有多种其他选择。 FTP 通常以正确的用户身份运行,使文件所有权和权限变得轻而易举。许多商业(和 OSS)消费级 PHP 包使用 FTP 技巧来使事情变得更加顺利。

尽管正如其他人所提到的,如果您的目标是极客、拥有自己的机器(专用或虚拟化)的人或消费级市场以外的任何其他人,那么 PEAR 或 PEAR2 发行版会取悦人们,并且如果您仅针对 5.3 , Phar 发行版是完全合适的。

Is there a good way to create PHP installer scripts which write files that have user-tinkering-friendly ownership and permissions?

I've only ever seen this pulled off successfully using one method, and it's horrible/funny: FTP. The FTP extension is usually enabled, and when it isn't, you have a variety of other options. FTP usually operates as the correct user, making file ownership and permissions a breeze. Many commercial (and OSS) consumer-grade PHP packages use FTP trickery to make things a bit more smooth.

Though as mentioned by others, if you're targeting geeks, people with their own machines (dedicated or virtualized) or anything other than the consumer-grade market, a PEAR or PEAR2 distro would please people, and if you're targeting 5.3 only, a phar distro is completely suitable.

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