我有许多具有相同配置的 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 上运行相同的配置时出现错误:
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
不幸的是,我找不到在 Apache 2.4 中使用我的配置的方法。请帮忙解决问题。
答案1
我联系了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 :)
... 2014 年 7 月 13 日(星期日) 23:21:42 UTC 添加了一个新端口:
- 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.
答案2
我不熟悉 FreeBSD,但你必须以某种方式为 apache 2.4 安装 MPM-ITK。例如,在 Ubuntu 中,它会是这样的sudo apt-get install apache2-mpm-itk
然后,必须在 apache 配置中启用 MPM-ITK 模块。取消注释/添加下面的行即可。
LoadModule mpm_event_module /path/to/apache2/modules/mod_mpm_itk.so
此外,allow from all
在 apache2.4 中不再有效;应该是Require all granted
。一旦安装了,下面的 vhost 应该就可以工作了mpm-itk
。
<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>
答案3
如果有人正在使用 CentOS 7.1,那么以下是对我有用的方法:
- 配置 EPEL,以便你可以从该仓库“yum install”软件包
安装 httpd-itk 包:
]# yum install httpd-itk
- 编辑 /etc/httpd/conf.modules.d/00-mpm-itk.conf,删除“LoadModule”指令之前的注释
创建您的系统用户帐户(用于 VirtualHost 块)
]# useradd -r itkuser
- 编辑您的 VirtualHost(下面的示例是最小的)——我们正在请求“example.com”在 itkuser 系统组内的 itkuser 系统帐户所拥有的 Apache 线程上运行。
<VirtualHost *:80> DocumentRoot /var/www/html/dpumc.net ServerName example.com AssignUserID itkuser itkuser </VirtualHost>
- 重新启动 httpd