Search code examples
perlapachemod-perlmod-perl2

Write a simple mod_perl handler


I want to write a simple mod_perl handler which returns the local time like described on this page (http://perl.apache.org/docs/2.0/user/handlers/intro.html), but where have I to locate this file to access it.

I'm using Ubuntu but don't have a directory called MyApache2. So where to locate this file to try the functionality?


Solution

  • This is just an example. You need to create the files yourself. (You'll see your example refers to "file:MyApache2/CurrentTime.pm").

    mkdir -p example-lib/MyApache2
    touch example-lib/MyApache2/CurrentTime.pm
    

    Then paste the contents from the example into the file you just created.

    In order for this to run under mod_perl, you'll also have to let the server know where your MyApache2 is located. You should be able to add something like this to your Apache config:

    PerlSwitches -I/path/to/example-lib
    

    Don't forget to restart Apache before you test this out.