Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Following the instructions on Apache's site I have added the following to the end of my httpd.conf file:

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]

When I run service httpd start I get the following error:

RewriteMap: file for map vhost not found:/web-data/vhost.map

I've triple checked that the file is present, with read permissions, and that the spelling is correct in the reference. What could I be missing?

Edit

Results of 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
share|improve this question
    
Could be the path to /web-data/vhost.map. If the relative path isn't working, try its absolute version. –  KM. Jan 27 at 20:34
    
/web-data/ is a root level directory so that is an absolute path. –  LoneWolfPR Jan 27 at 20:37
    
Are you running Linux of some flavor and have SELinux enabled by chance? Look in your syslogs if you see anything there. Examine/post the output of ls -lZ on /web-data (-Z displays SELinux contexts) –  KM. Jan 27 at 20:41
    
added to the post. –  LoneWolfPR Jan 27 at 20:45

1 Answer 1

up vote 1 down vote accepted

Compare the output of ls -lZ /var/www/html and ls -lZ /web-data. Also, examine your syslog, there should be a corresponding SELinux error with details.

In the interim, try the following:

  1. Change the context of /web-data to match that of /var/www/html using the chcon command, something like:

    chcon --reference=/var/www/html /web-data

  2. Discouraged: You can also temporarily disable SELinux and see if the error goes away

share|improve this answer
    
Can't find any errors related to this in any logs. –  LoneWolfPR Jan 27 at 21:22
1  
You were basically right though. I had to change my context for /web-data/ and all it's children. I used chcon -Rt httpd_sys_content_t /web-data/ –  LoneWolfPR Jan 27 at 21:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.