自动 775 权限

自动 775 权限

伙计们,我有一个 Linux 专用服务器。

有多个用户管理服务器上的特定目录。

但是如果用户上传了某些内容,例如插件/库。执行时,它会创建该插件/库所需的子目录。用户没有该目录的权限。

如何自动给所有目录赋予775权限?

答案1

接收上传的服务器的 umask 必须设置为002,然后新创建的目录将获得权限775

答案2

find /path/to/base/dir -type d -exec chmod -R 755 {} +;

将递归更改文件夹的权限。您可以设置一个 cron 作业来自动执行此操作,或者根据需要从插件根目录执行它。

答案3

将用户添加到 apache/php 组

usermod -g 组用户名

关注上传的文件

/usr/bin/inotifywait -e create -e attrib \
    -mrq /home/project/public_html/plugins | while read file; do
    echo -n "$file " >> /var/log/uploads_monitor.log
    echo `date | cut -d " " -f1-4` >> /var/log/uploads_monitor.log
    chmod 775 $file >/dev/null 2>&1
done

答案4

我建议你看看ruid2预构建包),它允许对域的所有 HTTP 请求以该域的所有者身份运行,而不是以 Apache 用户身份运行。对此的抱怨之一是它无法与 FastCGI 一起正常运行

这是我在 CentOS 6 x86_64 服务器上加载它的方法:

  1. 作为cd 到/root
  2. 下载最新原子释放转速http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/
  3. 安装原子释放转速:rpm -Uvh atomic-release*rpm
  4. 安装mod_ruid2rpm 包:yum install mod_ruid2

这将导致您的操作系统上出现以下文件:

  1. /etc/httpd/conf.d/ruid2.conf
  2. /usr/lib64/httpd/modules/mod_ruid2.so
  3. /usr/share/doc/mod_ruid2-0.9.1/
  4. /usr/share/doc/mod_ruid2-0.9.1/LICENSE
  5. /usr/share/doc/mod_ruid2-0.9.1/README

安装 mod_ruid2-0.9.6-3.el6.art.x86_64(或当前版本)后,运行命令“apachectl -t -D DUMP_MODULES”

寻找类似这样的结果:

Loaded Modules:
  core_module (static)
  mpm_prefork_module (static)
  http_module (static)
  so_module (static)
  auth_basic_module (shared)
  auth_digest_module (shared)
  authn_file_module (shared)
  authn_alias_module (shared)
  authn_anon_module (shared)
  authn_dbm_module (shared)
  authn_default_module (shared)
  authz_host_module (shared)
  authz_user_module (shared)
  authz_owner_module (shared)
  authz_groupfile_module (shared)
  authz_dbm_module (shared)
  authz_default_module (shared)
  ldap_module (shared)
  authnz_ldap_module (shared)
  include_module (shared)
  log_config_module (shared)
  logio_module (shared)
  env_module (shared)
  ext_filter_module (shared)
  mime_magic_module (shared)
  expires_module (shared)
  deflate_module (shared)
  headers_module (shared)
  usertrack_module (shared)
  setenvif_module (shared)
  mime_module (shared)
  dav_module (shared)
  status_module (shared)
  autoindex_module (shared)
  info_module (shared)
  dav_fs_module (shared)
  vhost_alias_module (shared)
  negotiation_module (shared)
  dir_module (shared)
  actions_module (shared)
  speling_module (shared)
  userdir_module (shared)
  alias_module (shared)
  substitute_module (shared)
  rewrite_module (shared)
  proxy_module (shared)
  proxy_balancer_module (shared)
  proxy_ftp_module (shared)
  proxy_http_module (shared)
  proxy_ajp_module (shared)
  proxy_connect_module (shared)
  cache_module (shared)
  suexec_module (shared)
  disk_cache_module (shared)
  cgi_module (shared)
  version_module (shared)
  fcgid_module (shared)
  perl_module (shared)
  php5_module (shared)
  python_module (shared)
  ruid2_module (shared)
  ssl_module (shared)

如果有的话,你就可以出发了。

接下来,对文件进行必要的添加ruid2.conf

请注意,由于 Plesk 使用路径设置了我的主帐户/var/www/vhosts/mydomain.com/httpdocs,因此我首先添加了以下内容:

<Directory /var/www/vhosts/mydomain.com/httpdocs>
  RMode stat
  RUidGid apache apache
  RGroups apache psaserv
</Directory>

然后,它使用该路径设置了其他域网站/var/www/vhosts/mydomain.com/myotherdomain.com,因此我为每个域网站添加了以下内容:

<Directory /var/www/vhosts/mydomain.com/myotherdomain.com>
  RMode stat
  RUidGid apache apache
  RGroups apache psaserv
</Directory>

相关内容