升级到Apache 2.4:VirtualHost命令无效“AssignUserID”

我有很多具有相同configuration的Apache 2.2虚拟主机

<VirtualHost *:80> ServerAdmin [email protected] ServerName site.com ServerAlias www.site.com DocumentRoot /home/site.com/htdocs/ ErrorLog /home/site.com/logs/error.log CustomLog /home/site.com/logs/access.log common AssignUserID site.com ftp <Directory /home/site.com/htdocs/> DirectoryIndex index.html index.htm index.php Options Includes FollowSymLinks SymLinksIfOwnerMatch AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 

尝试在Apache 2.4上运行相同的configuration时出现错误:

 Performing sanity check on apache24 configuration: AH00526: Syntax error on line 8 of /usr/local/etc/apache24/Includes/site.com.conf: Invalid command 'AssignUserID', perhaps misspelled or defined by a module not included in the server configuration 

不幸的是我找不到一种方法来使用我的configuration与Apache 2.4。 帮助解决问题。

我联系了ports apache24的维护者:

 You need to load mpm-itk into apache 2.4. There is pending port with mpm-itk for apache 2.4: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=188992 It's waiting for almost three months for some good soul to pick it up :) 

… Sun Jul 13 23:21:42 UTC 2014添加了一个新的端口:

 - new port mod_mpm_itk for apache24 apache2-mpm-itk (just mpm-itk for short) is an MPM (Multi-Processing Module) for the Apache web server. mpm-itk allows you to run each of your vhost under a separate uid and gid - in short, the scripts and configuration files for one vhost no longer have to be readable for all the other vhosts. 

我对FreeBSD不熟悉,但是你将不得不为apache 2.4安装MPM-ITK。 例如,在Ubuntu中,它会像sudo apt-get install apache2-mpm-itk

然后,必须在apacheconfiguration中启用MPM-ITK模块。 取消/添加下面的行应该做的工作。

 LoadModule mpm_event_module /path/to/apache2/modules/mod_mpm_itk.so 

此外, allow from all apache2.4不再工作; 应该Require all granted 。 一旦你安装了mpm-itk下面的vhost应该可以工作。

 <VirtualHost *:80> ServerAdmin [email protected] ServerName site.com ServerAlias www.site.com DocumentRoot /home/site.com/htdocs/ ErrorLog /home/site.com/logs/error.log CustomLog /home/site.com/logs/access.log common AssignUserID site.com ftp <Directory /home/site.com/htdocs/> DirectoryIndex index.html index.htm index.php Options Includes FollowSymLinks SymLinksIfOwnerMatch AllowOverride All Require all granted </Directory> </VirtualHost> 

如果有人正在使用CentOS 7.1,下面是适合我的方法:

  1. configurationEPEL,以便您可以从该回购“安装”软件包
  2. 安装httpd-itk软件包:

    ]# yum install httpd-itk

  3. 编辑/etc/httpd/conf.modules.d/00-mpm-itk.conf,在“LoadModule”指令前删除注释
  4. 创build您的系统用户帐户(将在VirtualHost块中使用)

    ]# useradd -r itkuser

  5. 编辑您的VirtualHost(下面的示例是最小的) – 我们正在请求“example.com”在itkuser系统组中的itkuser系统帐户拥有的Apache线程上运行。

    <VirtualHost *:80> DocumentRoot /var/www/html/dpumc.net ServerName example.com AssignUserID itkuser itkuser </VirtualHost>

  6. 重新启动httpd