Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 33149 - commonapache2.conf file in apache ebuild sets wrong settings for mod_perl
Summary: commonapache2.conf file in apache ebuild sets wrong settings for mod_perl
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Apache Team - Bugzilla Reports
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-10 07:09 UTC by Haroon Rafique
Modified: 2005-01-22 00:33 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Haroon Rafique 2003-11-10 07:09:53 UTC
I've been running mod_perl 2 (1.99_10) since the early days with apache 2.
I noticed that some of the settings in the commonapache2.conf file in the
<IfModule mod_perl.c> sections are written in mod_perl 1 syntax and will not
work in mod_perl 2.

Here are a few examples (first file shows the correct mod_perl 2 synatx):

694c694
<         PerlResponseHandler Apache::Status
---
>         PerlResponseHandler ModPerl::Status

875c875
<         PerlOptions +ParseHeaders
---
>         PerlSendHeader On
906c906
<     PerlModule ModPerl::Registry
---
>     PerlModule Apache2::ModPerl::Registry
912c912
<         PerlOptions +ParseHeaders
---
>         PerlSendHeader On
920c920
<         PerlOptions +ParseHeaders
---
>         PerlSendHeader On

Perhaps this can be taken care of soon, so that new users won't have
to tinker with their default setup at all.
Comment 1 David Stanek 2004-04-14 09:58:38 UTC
Having the mod_perl1 directives seems to be ok for now, because mod_perl is only at version 1.27-r4 in portage.  I presume anyone that is able to install a newer version by hand will also be able to update the configs.

This does, however, create an issue when mod_perl2 is included in portage.  According to the mod_perl documentation you can use the MODPERL2 symbol in the configs.  The mod_perl documentation is pretty clear on what changes need to be made to convert to mod_perl2.  I am gonna convert the apache 2.0.49 configs tonight and post a potential patch. 

From: http://perl.apache.org/docs/2.0/user/config/config.html#C_MODPERL2__Define_Option

When running under mod_perl 2.0 a special configuration "define" symbol MODPERL2 is enabled internally, as if the server had been started with -DMODPERL2. For example this can be used to write a configuration file which needs to do something different whether it's running under mod_perl 1.0 or 2.0:

  <IfDefine MODPERL2>
      # 2.0 configuration
  </IfDefine>
  <IfDefine !MODPERL2>
      # else
  </IfDefine>
Comment 2 Chuck Short (RETIRED) gentoo-dev 2004-04-15 07:00:59 UTC
Ill have a look when I get back today.

Thanks
chuck
Comment 3 Chuck Short (RETIRED) gentoo-dev 2004-04-15 15:45:20 UTC
Fixed in cvs, thanks for the bug report.
Comment 4 Peter Colijn 2004-04-17 16:03:05 UTC
Er, this happened to screw mod_perl2 and apache2 up for me. In particular, this change:

906c906
<     PerlModule ModPerl::Registry
---
>     PerlModule Apache2::ModPerl::Registry

Made apache unable to locate the module, so I got a 500 error for all my CGI/Perl pages. It would appear that this "fix" doesn't work in all cases.

Setting the <IfDefine MODPERL2> config equal to the config for <IfDefine !MODPERL2> fixed the problem for me.

I am running apache 2.0.49-r1 with mod_perl 1.99.11 and perl 5.8.3. I did fresh emerges of all them and still had this problem, and I don't have any old copies of any of those packages lying around either. The scripts it failed on are in my server's "/perl/", which is set up by default in the commonapache2.conf file, so I doubt it's a configuration error on my part.
Comment 5 Haroon Rafique 2004-04-19 05:43:29 UTC
Peter,

The diff in the description states that the first file shows the correct syntax. I should have posted the diff with the old file first and new (corrected syntax) file last.

In any case, the diff shown for line 906 means PerlModule ModPerl::Registry is the correct syntax. Can you confirm that you cannot initialize mod_perl with that line in your /etc/apache2/conf/commonapache2.conf?

I don't know why people are suggesting use of <IfDefine MODPERL2>. Have you not noticed that there is a SEPARATE file for apache 1/mod_perl1 called /etc/apache/conf/commonapache.conf. If Gentoo was keeping one single commonapache.conf file then we could advocate the use of <IfDefine MODPERL2>. Since that is not the case the use of <IfModule mod_perl.c> is sufficient, IMO.
Comment 6 Haroon Rafique 2004-04-19 06:29:07 UTC
Reopening bug as some directives are messed up. E.g., it shows in the commonapache2.conf file as follows:

        <IfDefine MODPERL2>
        PerlResponseHandler Apache2::ModPerl::Registry
        </IfDefine>
        <IfDefine !MODPERL2>
        PerlResponseHandler ModPerl::Registry
        </IfDefine>

This is wrong. It should be the other way around. ModPerl::Registry should be inside <IfDefine MODPERL2>.
I have already explained my rant about not having to use <IfDefine MODPERL2> in comment 5. Its totally redundant since there are already separate files commonapache.conf for mod_perl1 and commonapache2.conf for mod_perl2. Unless, automagically, apache1 can all of a sudden be used with the commonapache2.conf file, I would suggest dropping the <IfDefine>s all together and taking out the old synatx, please.

In addition, there is an "unprotected" line using the "bad syntax" on line 916. 
    PerlModule Apache2::ModPerl::Registry
Peter reported this in comment 4. I hadn't yet looked at the checked-in CVS code, so I was jumping to conclusions and couldn't understand what he was saying. Peter, sorry about not catching this. In any case, line 916 should either be protected by the <IfDefine> or better yet completely replaced by the correct syntax.
    PerlModule ModPerl::Registry
Comment 7 Haroon Rafique 2004-04-19 06:35:13 UTC
And you also missed a couple of lines which still have the old syntax.

        PerlSendHeader On

That should be
         PerlOptions +ParseHeaders

Cheers and thanks in advance.
Comment 8 Martin Mokrejš 2004-04-20 17:18:06 UTC
I went to test 2.0.49-r1 because was asked to check if bug #37039 is fix for me. Now, I can't even shutdown my old 2.0.49 because of this:

# /etc/init.d/apache2 stop
 * Stopping apache2...
[Wed Apr 21 02:05:03 2004] [crit] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.
Pre-configuration failed\n
#

As I did update the config files, here's exactly what went wrong:

--- /etc/apache2/conf/commonapache2.conf        2004-03-18 01:35:28.000000000 +0100
+++ /etc/apache2/conf/._cfg0000_commonapache2.conf      2004-04-21 01:55:09.000000000 +0200
@@ -1,5 +1,5 @@
 ### /etc/apache2/conf/commonapache2.conf
-### $Id: commonapache2.conf,v 1.8 2003/09/27 04:47:18 woodchip Exp $
+### $Id: commonapache2.conf,v 1.3 2004/04/16 11:24:39 zul Exp $
 ###
 ### Common server configuration.
 ###
@@ -414,7 +414,7 @@
     # reasons in browsers, related to javascript and URL parsing
     # which encourage you to always set a default char set.
     #
-    AddDefaultCharset ISO-8859-2
+    AddDefaultCharset ISO-8859-1
 
     # LanguagePriority allows you to give precedence to some languages
     # in case of a tie during content negotiation.
@@ -691,7 +691,12 @@
 <IfModule mod_perl.c>
     <Location /perl-status>
         SetHandler perl-script
+       <IfDefine MODPERL2>
+       PerlResponseHandler Apache::Status
+       </IfDefine>
+       <IfDefine !MODPERL2>
         PerlResponseHandler ModPerl::Status
+       </IfDefine>
         <IfModule mod_access.c>
           Order deny,allow
           Deny from all
@@ -872,7 +877,12 @@
         SetHandler perl-script
         PerlResponseHandler ModPerl::PerlRun
         Options -Indexes ExecCGI
-        PerlSendHeader On
+       <IfDefine MODPERL2>
+         PerlOptions +ParseHeaders
+       </IfDefine>
+       <IfDefine !MODPERL2>
+          PerlSendHeader On
+       </IfDefine>
     </Directory>
 </IfModule>
 
@@ -907,7 +917,12 @@
     #set Apache::Registry Mode for /perl Alias
     <Location /perl/*.pl>
         SetHandler perl-script
+       <IfDefine MODPERL2>
+        PerlResponseHandler Apache2::ModPerl::Registry
+       </IfDefine>
+       <IfDefine !MODPERL2>
         PerlResponseHandler ModPerl::Registry
+       </IfDefine>
         Options -Indexes ExecCGI
         PerlSendHeader On
     </Location>
End of differences between /etc/apache2/conf/commonapache2.conf and /etc/apache2/conf/._cfg0000_commonapache2.conf
1) Replace original with update
2) Delete update, keeping original as is
3) Interactively merge original with update
4) Show differences again
Please select from the menu above (-1 to ignore this update): 1
Replacing /etc/apache2/conf/commonapache2.conf with /etc/apache2/conf/._cfg0000_commonapache2.conf
mv: overwrite `/etc/apache2/conf/commonapache2.conf'? y

Exiting: Nothing left to do; exiting. :)
#

Feel free to figure out what is wrong.

Please test that the thread issue is resolved before making new apache2 release. Test with ssl and php enabled. I think I some config file I always have to set "-DPHP4 -DSSL -DMAILMAN" ... it too late to grep for it now. Anyway, it's clear what your should cross-check together.
Comment 9 David Stanek 2004-05-15 20:54:56 UTC
Martin, there are lots of reports out there on the net about PHP not working correctly on Apache2. Try to emerge apache2 again using USE="-threads". This may help. If not try to emerge php using USE="apache2".
Comment 10 Benedikt Böhm (RETIRED) gentoo-dev 2005-01-22 00:33:00 UTC
This should be solved with the new configuration layout the apache herd introduces in his (currently) hard masked packages. please test it.

Upgrade Instructions:
---------------------

After we have refreshed the packages on 8th Jan, to upgrade you will need to
do the following.

If you do not want to install masked/unstable packages on your machine(s),
these ebuilds will be unmasked and marked stable as soon as we have
determined that everything is working properly.

- unmask all needed packages (using /etc/portage/package.unmask and
  /etc/portage/package.keywords)
- emerge -uav world

With this update, we are bringing some changes to the Apache configuration:

- /etc/apache{,2}/conf is moving to be /etc/apache{,2}
- new httpd.conf replaces commonapache{,2}.conf and apache{,2}.conf files
- /etc/apache{,2}/conf/vhosts is moving to be /etc/apache{,2}/vhosts.d

After installing this update, you will need to manually migrate any changes
you've made to your existing configuration files into the new configuration
files.

See http://dev.gentoo.org/~vericgar/package-refresh.txt