LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache: Invalid command 'SetEnvIfNoCase', (http://www.linuxquestions.org/questions/linux-server-73/apache-invalid-command-setenvifnocase-884484/)

grob115 06-04-2011 05:51 AM

Apache: Invalid command 'SetEnvIfNoCase',
 
Hi, not sure why but Apache is complaining about an error with SetEnvIfNoCase when I tried to start it. I've checked that the module /usr/local/apache2/modules/mod_rewrite.so exists. Also the 2nd code block below shows that I'm using the <IfModule rewrite_module></IfModule> tags so if the module isn't available, Apache shouldn't have read that part of the file. The fact that it's reading inside that tag pair means it's able to load the mod_rewrite.so DSO. Any ideas?

Code:

[root@test httpd-2.2.19]# service httpd restart
Stopping httpd:                                            [FAILED]
Starting httpd: Syntax error on line 203 of /usr/local/apache2/conf/httpd.conf:
Invalid command 'SetEnvIfNoCase', perhaps misspelled or defined by a module not included in the server configuration
                                                          [FAILED]

Line 203 is the following highlighted in bold.
Quote:

<IfModule rewrite_module>
RewriteEngine On
SetEnvIfNoCase Referer "^http://192.168.10.9/" good
<FilesMatch "\.(png|jpg|jpeg|gif|bmp|swf|flv)$">
Order Deny,Allow
Deny from all
Allow from env=good
#ErrorDocument 403 http://www.google.com/intl/en_ALL/images/logo.gif
#ErrorDocument 403 /images/you_bad_hotlinker.gif
ErrorDocument 403 "No hot link allowed"
</FilesMatch>
SetEnvIfNoCase User-Agent "^Wget" malicious_agent
<Limit GET POST>
Order Allow,Deny
Allow from all
Deny from env=malicious_agent
</Limit>
</IfModule>

acid_kewpie 06-04-2011 06:34 AM

This is nothing to do with mod_rerwite you need to make sure the setenvif module is loaded first - http://httpd.apache.org/docs/current..._setenvif.html

grob115 06-04-2011 07:51 AM

Hi, thanks. You saved my day. Turns out there were a few more modules I needed to load and they call can be looked up from here based on the Directives being used.

grob115 06-04-2011 08:37 AM

Um... something is not adding up. For some reason, I'm now seeing a bunch of the following.
Code:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in [path]/includes/functions.php on line 3461
I have the following setup
Server--------Modules Directory------Configure Command
A---------httpd.exp, libphp5.so------Can't remember
B---------All the modules available--configure --prefix=/usr/local/apache2 --enable-mods-shared=all

The interesting thing is the httpd.conf from Server A works just fine but as soon as I put it into Server B, it complains about all sorts of Directives having issues unless I load the respective modules as we've discovered above. However, once all the modules are loaded, Server B would give me the above timezone setting errors, and also wouldn't know that it should load up the index.php or index.html page on its own.

Is this due to the way Apache was configured? I can't remember what was the command I used to install Apache on Server A but am suspecting that it was without the "--enable-mods-shared=all" option as it doesn't have all the modules.

bathory 06-04-2011 08:54 AM

Quote:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in [path]/includes/functions.php on line 3461
This is a php warning. You can edit php.ini and use
Code:

date.timezone = America/Los_Angeles
or whatever timezone you're in.

Regards

grob115 06-04-2011 09:05 AM

Thanks. Just recompiled Apache using the following but this time the modules directory only has httpd.exp (ie libphp5.so is missing). Any idea what options would produce just these two files? I'm wondering the difference in behavior might have been due to the way it was configured?
Code:

./configure --prefix=/usr/local/apache2
Also looked at the Apache documentation here. I'm a bit puzzled by the following statement on the page. So what's the point of the "all" keyword?
Quote:

Caveat: --enable-mods-shared=all does not actually build all modules. To build all modules then, one might use:

./configure \
--with-ldap \
--enable-mods-shared="all ssl ldap cache proxy authn_alias mem_cache file_cache authnz_ldap charset_lite dav_lock disk_cache"

bathory 06-04-2011 10:16 AM

You need to use "--enable-so" if you want to be able to build additional apache modules (like the php module libphp5.so)

Have a look at table 3.3 here to see why you need to explicitly name some modules in the ./configure options

Regards

grob115 06-04-2011 10:50 AM

Thanks for the link. Observed the following:
1) The libphp5.so comes from the PHP installation and requires running the PHP's make clean, configure, make, and make install command in order to get it installed into Apache's module directory.
2) After compiling Apache again without the "--enable-mods-shared=all" option, and doing the steps for PHP in step 1 above, the same two files (shown below) I observed before are back. This suggests that Server A initially was built without the "--enable-mods-shared=all" option.
Quote:

[root@test modules]# ls -l
total 22208
-rw-r--r-- 1 root root 9083 Jun 4 07:29 httpd.exp
-rwxr-xr-x 1 root root 22689103 Jun 4 08:10 libphp5.so
With this, executing "service httpd start" I got the following.

Apache was built without "--enable-mods-shared=all" option
Quote:

Starting httpd: httpd: Syntax error on line 87 of /usr/local/apache2/conf/httpd.conf: module setenvif_module is built-in and can't be loaded
[FAILED]
In contrast, the behavior is completely the opposite if I use the "--enable-mods-shared=all" option. This is interesting as initially I also didn't have the "setenvif_module" loaded, and then run into the issue with the Directive "SetEnvIfNoCase", thus starting this thread asking for help.

Apache was built with "--enable-mods-shared=all" option
Quote:

Starting httpd: Syntax error on line 203 of /usr/local/apache2/conf/httpd.conf:
Invalid command 'SetEnvIfNoCase', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]


All times are GMT -5. The time now is 05:57 PM.