Find the answer to your Linux question:
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 28
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11

    /etc/apache2/sites-available/default: ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    I would say that according to that, your CGI dir is /usr/lib/cgi-bin/, do you think that is right?

    chdir to that dir and see what is in there. If you find any *.cgi or *.pl files, try to load them in a browser, using the 2nd parameter inthe ScriptAlias line as your path relative to the server root. i.e., if there is a file called /usr/lib/cgi-bin/test.cgi (and it is marked executable), the on the same machine, launch a browser and go to:


    Hopefully you'll get the output of whatever script you've found.

    If there is not one there, just open your editor (as root) and in it put:

    print "Content-type:text/html\n\n";
    print "Hello from <b>$0</b>\n";
    then save it as /usr/lib/cgi-bin/ and make it executable:
    chmod +x /usr/lib/cgi-bin/
    then execute it from the command line to make sure it works:

    # cd /usr/lib/cgi-bin
    # ./ 
    Hello from <b>./</b>
    then if all is well, load it in your browser:


    If you can get that far, then we can try your other scripts.

  2. #12
    Just Joined!
    Join Date
    Sep 2012

    Default location -

    Permission -
    ls -lZd /var/www/cgi-bin/search

    Permission should be
    Directory permission - 755
    File permission - 644

    this permission should also be present on the parent directory

    ls -l /var/www/cgi-bin/search/search.html

    644 - should have read and execute permission on the file.

    Configuration file:-
    It will use default configuration which allow to execute the scripts present in cgi-bin
    but if you have made changes in configuration file , please list the configuration file details.

    Its an important factor , don't ignore it.
    First check if the selinux is enabled or not

    if SELINUX is enabled , then change the selinux in permissive mode and execute the URL.

    if in enabled mode then perform following steps

     restorecon -RFv /var/www/cgi-bin/
     setsebool -P httpd_enable_cgi=0
    Check following log file

    If you are still facing problems please post the errors.

    Best Wishes

  3. #13
    Hi, sorry I have not replied in a while. I did have my cgi-bin in /usr/lib/ but there was only a license.txt file in it. When I try to go to localhost/cgi-bin/ i get "Forbidden You don't have permission to access /cgi-bin/ on this server. Apache/2.2.14 (Ubuntu) Server at localhost Port 80" I did chmod +x on the cgi-bin and search folder but that had no effect. Then I did chmod -R 777 on the same directories, still no effect. I put the script in the cgi-bin and made it executable. I tried to access it from localhost and still got the same error.

  4. $spacer_open
  5. #14
    actually the localhost/cgi-bin/ script did work i had typed in my browser wrong, but It worked i got:

    Hello from /usr/lib/cgi-bin/

  6. #15
    Quote Originally Posted by killa_cam View Post
    actually the localhost/cgi-bin/ script did work i had typed in my browser wrong, but It worked i got:

    Hello from /usr/lib/cgi-bin/
    well that's good.

    so try this:
    cd /tmp
    python > searchoutput.html
    echo $?
    if the echo $? does not return 0, then post the content of searchoutput.html. or post the contents if they look like they contain an error.

    If all does look well, copy the files to your cgi-bin dir:

    sudo cp -i /tmp/* /usr/lib/cgi-bin/
    then try and load it in a browser and see what happens:
    firefox http://localhost/cgi-bin/Search.html

  7. #16
    Alright so everything went well except "firefox localhost/cgi-bin/Search.html" for that command I got:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.
    Apache/2.2.14 (Ubuntu) Server at localhost Port 80

  8. #17
    after you ran this command:
    python > searchoutput.html
    what is in the file "searchoutput.html"?

    also, what is in the Apache logs after you try and load Search.html in a browser?

  9. #18
    The file "searchoutput.html" seems to be empty and my var/log/apache2/error.log said:

    [Thu Nov 08 20:52:39 2012] [error] [client ::1] (13)Permission denied: exec of '/usr/lib/cgi-bin/Search.html' failed

    and then after i refreshed it:

    [Thu Nov 08 20:52:39 2012] [error] [client ::1] Premature end of script headers: Search.html

  10. #19
    okay, so i guess it only wants scripts in that dir. try this:

    # make a directory under the DocumentRoot to hold the files
    sudo mkdir /var/www/search
    # copy (or move) the files there
    sudo cp -i /usr/lib/cgi-bin/[sS]* /var/www/search/
    then try this URL:


  11. #20
    After entering the commands and trying to access localhost/search/search.html

    The requested URL /search/cgi-bin/ was not found on this server.

    Apache/2.2.14 (Ubuntu) Server at localhost Port 80

    The searchoutput.html now has text in it but in the search.html it says

    <form action="cgi-bin/" method="POST">

    im not sure if that should be submitting to cgi-bin/ or not but that may also be a problem

Posting Permissions

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