rianne_k has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am using mod_perl and Apache to run cgi scripts. I had some problems with the perl Modules Crypt::SSLeay and LWP::UserAgent, so I have removed and reinstalled some modules. But then when I tried to restart the Apache server, I get the message:

sudo /etc/init.d/apache2 reload Syntax error on line 5 of /etc/apache2/httpd.conf: Invalid command 'PerlResponseHandler', perhaps misspelled or defined b +y a module not included in the server configuration Action 'configtest' failed. The Apache error log may have more information. ...fail!

Before it was working fine, there are no misspellings in the configuration file. Any ideas on what is going wrong ?

Thanks!!

Rianne

Replies are listed 'Best First'.
Re: Apache Server restart fails
by Anonymous Monk on Mar 02, 2012 at 13:27 UTC
    Syntax error on line 5 of /etc/apache2/httpd.conf:

    Would you paste the first ten lines or so of httpd.conf? (so that people can vet it for correctness)

    I suspect your problem is that the mod_perl module was left unloaded. Some popular server OSes use symbolic links to tell which apache modules to load. Poke around /etc/apache2/, particularly the mods-available and mods-enabled directories, if they exist.

      This is my httpd.conf file:
      Alias /www /home/Documents/ <Directory /home/Documents/*/perl/> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders AddHandler cgi-script .cgi Options +ExecCGI </Directory>
      The mods-available and mods-enabled directories exist, and there is a bunch of .load files in them. What should I look for there?

        I am guessing you are using a Debian-based distribution, then.

        If so, you can type a2enmod perl to create the appropriate symlink.

        If not, you should find a .load file in mods-available that loads the mod_perl .so file, and create a symbolic link of that file to mods-enabled, like this:

        # cd /etc/apache2/mods-enabled # ln -s ../mods-available/perl.load .

        Oh, and in the case it /is/ a debian-based distribution, please paste the output of dpkg -l|fgrep apache, so we can look for any missing packages. You should at least have libapache2-mod-perl2 (if you installed mod_perl through your distribution's package manager (which is highly recommended))

Re: Apache Server restart fails
by zwon (Abbot) on Mar 02, 2012 at 13:32 UTC
    Invalid command 'PerlResponseHandler', perhaps misspelled or defined by a module not included in the server configuration

    So you maybe removed mod_perl? Diff between old and new configurations would be helpful.

Re: Apache Server restart fails
by Anonymous Monk on Mar 02, 2012 at 11:40 UTC

    The Apache error log may have more information.

    :) uc " look in the log "

      I did, the Apache error log, didn't log any errors or warnings.
Re: Apache Server restart fails
by locked_user sundialsvc4 (Abbot) on Mar 02, 2012 at 13:53 UTC

    Without a doubt, the root cause of the problem is that the Perl-handling module that you are using failed to load.   Modules have the opportunity to look at all of the configuration-file directives, and no one’s saying that they recognize this one.   Ergo, the module that is supposed to be doing that, isn’t there anymore.   Either it isn’t specified in the config anymore, or it’s not loading successfully.

      I checked if ModPerl::Registry was installed, and that is not the case. I am not sure if it was installed before. Anyway, when I try to install ModPerl::Registry in CPAN, it fails with the error message:
      [ error] Unable to open /etc/apache2/ap_release.h: No such file or di +rectory [ error] Unable to determine server version, aborting. [ error] Please specify MP_APXS or MP_AP_PREFIX. Warning: No success on command[/usr/local/bin/perl Makefile.PL INSTALL +DIRS=site] 'YAML' not installed, will not store persistent state PHRED/mod_perl-2.0.5.tar.gz /usr/local/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK Running make test Make had some problems, won't test Running make install Make had some problems, won't install Could not read metadata file. Falling back to other methods to determi +ne prerequisites Failed during this command: PHRED/mod_perl-2.0.5.tar.gz : writemakefile NO '/usr +/local/bin/perl Makefile.PL INSTALLDIRS=site' returned status 256
      It can't find some apache2 file ap_release.h. I remember seeing this error message before all these problems occurred though.

        To install that module manually, you need to have the apache development headers installed. (I am not sure this is the cause of your problem, though)

        Anyway, it is frowned upon that you replaced your node's content in whole, especially after someone already replied to it.

        "Perl-handling module" as in the Apache module that provides the PerlResponseHandler etc directives. That is, mod_perl. Anyway, I'm with zwon here that you either removed or disabled mod_perl by accident somewhere along the way.

Re: Apache Server restart fails
by rianne_k (Novice) on Mar 05, 2012 at 13:47 UTC
    I've been trying to remove and reinstall perl, Apache and Mod_perl, but now I'm going around in circles. When I try to reload the Apache server I still get the error:
    sudo /etc/init.d/apache2 reload [sudo] password for rianne: apache2: Syntax error on line 207 of /etc/apache2/apache2.conf: Syntax + error on line 8 of /etc/apache2/httpd.conf: Cannot load /usr/lib/apa +che2/modules/mod_perl.so into server: /usr/lib/apache2/modules/mod_pe +rl.so: cannot open shared object file: No such file or directory Action 'configtest' failed. The Apache error log may have more information. ...fail!
    So it cannot find the mod_perl.so file, which indeed is not in that directory. So I tried to reinstall mod_perl, but then I'm having issues with the Apache server. Inside the Mod_perl directory, the commands perl Makefile.PL MP_APXS=/usr/bin/apxs2 and make are fine, but when i run make test, I run into the following errors:
    make[2]: Leaving directory `/home/rianne/Software/mod_perl-2.0.5/mod_p +erl-2.0.5/xs/ModPerl' make[1]: Leaving directory `/home/rianne/Software/mod_perl-2.0.5/mod_p +erl-2.0.5/xs' /home/rianne/perl5/perlbrew/perls/perl-5.14.2/bin/perl -Iblib/arch -Ib +lib/lib \ t/TEST -clean [warning] setting ulimit to allow core files ulimit -c unlimited; /home/rianne/perl5/perlbrew/perls/perl-5.14.2/bin +/perl /home/rianne/Software/mod_perl-2.0.5/mod_perl-2.0.5/t/TEST -cle +an APACHE_TEST_GROUP= APACHE_TEST_HTTPD= APACHE_TEST_PORT= APACHE_TEST_US +ER= APACHE_TEST_APXS= \ /home/rianne/perl5/perlbrew/perls/perl-5.14.2/bin/perl -Iblib/arch + -Iblib/lib \ t/TEST -bugreport -verbose=0 [warning] setting ulimit to allow core files ulimit -c unlimited; /home/rianne/perl5/perlbrew/perls/perl-5.14.2/bin +/perl /home/rianne/Software/mod_perl-2.0.5/mod_perl-2.0.5/t/TEST -bug +report -verbose=0 APXS (/usr/bin/apxs2) query for PREFIX failed /usr/sbin/apache2 -d /home/rianne/Software/mod_perl-2.0.5/mod_perl-2. +0.5/t -f /home/rianne/Software/mod_perl-2.0.5/mod_perl-2.0.5/t/conf/h +ttpd.conf -D APACHE2 -D PERL_USEITHREADS using Apache/2.2.20 (worker MPM) waiting 120 seconds for server to start: .[Mon Mar 05 14:29:54 2012] [ +info] 6 Apache2:: modules loaded [Mon Mar 05 14:29:54 2012] [info] 0 APR:: modules loaded [Mon Mar 05 14:29:54 2012] [info] base server + 28 vhosts ready to run + tests APXS (/usr/bin/apxs2) query for PREFIX failed [ error] oh shucks, server dumped core [ error] for stacktrace, run: gdb /usr/sbin/apache2 -core /home/riann +e/Software/mod_perl-2.0.5/mod_perl-2.0.5/core [ error] server has died with status 255 (please examine t/logs/error_log) [ error] oh nuts, server dumped core [ error] for stacktrace, run: gdb /usr/sbin/apache2 -core /home/riann +e/Software/mod_perl-2.0.5/mod_perl-2.0.5/core Terminated make: *** [run_tests] Error 143 rianne@rianne-OXYL015:~/Software/mod_perl-2.0.5/mod_perl-2.0.5$ sudo / +etc/init.d/apache2 reload [sudo] password for rianne: apache2: Syntax error on line 207 of /etc/apache2/apache2.conf: Syntax + error on line 8 of /etc/apache2/httpd.conf: Cannot load /usr/lib/apa +che2/modules/mod_perl.so into server: /usr/lib/apache2/modules/mod_pe +rl.so: cannot open shared object file: No such file or directory Action 'configtest' failed. The Apache error log may have more information. ...fail!
    No error log messages appear in the Apache error and access log files and the error logs in t/logs/error_log in the mod_perl directory. Any ideas ? Thanks!