0

我想配置 apache 以创建具有个性化所有者的文件:组和 chmod。我有一个需要由 apache + (ftp) 用户操作的网站文件夹。

实际上我做了一个(其中'mygroup'是ftp用户组)

chown www-data:mygroup -R /my/website/files
chmod 770 -R /my/website/files

但是当 apache2 操作文件并创建文件或文件夹时,它们有

-rw-r--r-- 1 www-数据 www-data

配置 apache2 的任何想法?

编辑:Debian 6

4

2 回答 2

1

没有真正的方法可以做到这一点 AFAIK。库存版本的 Apache 没有一种机制可以根据请求在不同用户下生成工作人员。它的所有工作人员都在用户下运行,因此不能将文件写成另一个。


话虽如此,有一些方法可以解决这个问题。

The first way will require you to run Apache as root. Apache, as it sits on your server, is running under an unprivileged user. Unprivileged users can't change the user that they run under. Only processes run as root can do that. If you are willing to run your Apache as root, there is a multi-process mod available here. What it does is allow you to run each VHOST under a different user (defined in your config). That means you would now also need to set up each user with their own VHOST. This way would work, but you are sacrificing a bit of security by doing this.

The second, more secure, but more "hacky" way to do it would be to run completely new and individual version of Apache for each user. So you have an Apache with its own set of config files JUST for userA, another Apache with its own different and separate set of configs just for userB, etc. Each instance of Apache could listen on a different port (i.e. userA's listens on port 8080, userB on port 8081...). Then you could use some kind of front end reverse proxy to sort it all out and route the traffic to the appropriate Apache instance.

于 2012-10-10T19:27:05.557 回答
0

看起来你在 openSUSE 或 SLES 下工作。如果是这样,请查看文件/etc/apache2/uid.conf...

对于 umask:实际上不确定。当然可行的是在 apache 用户主目录下创建一个 .profile 文件并在其中设置 umask。但我敢打赌,有一个更优雅的解决方案!

于 2012-10-10T19:22:36.147 回答