遵循Apache网站上的说明,我在httpd.conf文件的末尾添加了以下内容:
RewriteEngine on RewriteMap lowercase int:tolower #define the map file RewriteMap vhost txt:/web-data/vhost.map # deal with aliases as above RewriteCond %{REQUEST_URI} !^/icons/ RewriteCond %{REQUEST_URI} !^/cgi-bin/ RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ # this does the file-based remap RewriteCond ${vhost:%1} ^(/.*)$ RewriteRule ^/(.*)$ %1/httpdocs/$1 RewriteCond %{REQUEST_URI} ^/cgi-bin/ RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ RewriteCond ${vhost:%1} ^(/.*)$ RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script]
当我运行service httpd start我得到以下错误:
RewriteMap: file for map vhost not found:/web-data/vhost.map
我已经三重检查了文件是否存在,具有读取权限,并且在引用中拼写是正确的。 我可以错过什么?
ls -lZ on /web-data/
drwxrwsr-x. root www unconfined_u:object_r:file_t:s0 logs drwx------. root root system_u:object_r:file_t:s0 lost+found -rw-r--r--. root www unconfined_u:object_r:file_t:s0 vhost.map drwxrwsr-x. root www unconfined_u:object_r:file_t:s0 vhosts
比较ls -lZ /var/www/html和ls -lZ /web-data 。 另外,检查你的系统日志,应该有一个相应的SELinux错误的细节。
在此期间,请尝试以下操作:
使用chcon命令更改/web-data的上下文以匹配/var/www/html的内容,如下所示:
chcon --reference=/var/www/html /web-data
不鼓励 :你也可以暂时禁用SELinux,看看错误是否消失