Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: mod_actions

  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    mod_actions

    after a very liberal xampp configuration on linux (testing), i can't seem to get apache to execute a cgi script whenever a .gif file has been requested. the apache documentation is straight forward, but I guess I'm not understanding something.

    my script will successfully write "success.txt" file to a web directory on my server if i call it directly from a browser....
    http://myserver/testdir/helloworld.pl

    this writes "success.txt" successfully. But not if a .gif file is requested as apache's mod_actions implies.

    in my httpd.conf file, i have....

    <directory /opt/lampp/htdocs/testdir>
    Options ExecCGI
    Action image/gif /opt/lampp/htdocs/testdir/helloworld.pl
    </directory>

    Thanks for any help.

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Never used mod_actions myself, but here are some other things to look at.

    Have you checked the server logs? Look at the access and error logs for anything weird.

    Does it work when using an extension instead of a MIME type? The documentation also lists that as an option.

    Do you have Firebug installed? If so, you could check out the http header/response for the gif and see if it is actually image/gif.
    Are you a Help Vampire?

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    O.k.,
    Ive set it up for using an extension rather than mime-type. For testing purposes, ive added my own extension (see my httpd.conf directive below).

    myscript.pl looks like:
    Code:
    #!/usr/bin/perl
    open (MYFILE, '>>data.txt');
    print MYFILE "Success!";
    close (MYFILE)
    script runs fine and writes data.txt when called directly in browser. no errors.

    my directive in httpd.conf looks like:
    Code:
    <Directory "/opt/lampp/htdocs/testdir">
    Options Indexes ExecCGI
    AddHandler my-file-type .xyz
    Action my-file-type myscript.pl
    </Directory>
    Now I restart lampp.
    Now I open a browser and request the file:http://localhost/testdir/blah.xyz
    What I get from the browser is a 400 (Bad Request).

    The error in the error log states:
    [ Wed Jan 13 11:04:03 2010 ] [error] [client 127.0.0.1] Invalid URI in Request GET /testdir/blah.xyz HTTP/1.1

    Any suggestions??? Thanks for helping.
    Last edited by geebers; 01-13-2010 at 05:47 PM.

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    I would bet that /opt/lampp/htdocs/opt in the log entry means it's looking for the whole /opt directory again under the htdocs directory. But I don't understand why. Can't see anything in what you've posted. Perhaps there's a config problem with setting up cgi?

    A Google search turned up this thread with the same problem. It briefly mentions at the end that a ScriptAlias needs to be set up first, but you've already done the AddHandler. I wonder if the handler isn't actually working correctly?

    Apologies. I can do just enough Apache config to keep things going, but this is outside of my experience.
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    geebers (01-13-2010)

  • #5
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    O.K. I've figured this out. I've removed my directive and just added the following 2 lines to httpd.conf

    AddHandler image/jpg .jpg
    Action image/jpg /cgi-bin/myscript.pl

    Just like the documentation says, DUH!!!
    I was just making it a lot more complicated than it needed to be.

    and now "data.txt" is written when an .jpg file is requested. It's o.k. that the actual .jpg file doesn't get displayed. That can be handled in my script as well if needed.

    Your advice to try to use a file extension rather than mime-type to handle .jpg files helped greatly. Thanks!!!
    Last edited by geebers; 01-13-2010 at 06:12 PM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •