Find the answer to your Linux question:
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 28
/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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353

    /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:

    http://localhost/cgi-bin/test.cgi

    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:

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

    Code:
    # cd /usr/lib/cgi-bin
    # ./hello.pl 
    Content-type:text/html
    
    Hello from <b>./hello.pl</b>
    then if all is well, load it in your browser:

    http://localhost/cgi-bin/hello.pl

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

  2. #12
    Just Joined!
    Join Date
    Sep 2012
    Location
    India
    Posts
    29
    Hi,

    Default location -
    /var/www/cgi-bin

    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.

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

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

    if in enabled mode then perform following steps

    Code:
     restorecon -RFv /var/www/cgi-bin/
    Code:
     setsebool -P httpd_enable_cgi=0
    Logs
    Check following log file
    /var/log/audit/audit.log
    /var/log/httpd/error.log
    /var/log/httpd/access.log

    If you are still facing problems please post the errors.

    Regards,
    Best Wishes

  3. #13
    Just Joined!
    Join Date
    Sep 2012
    Posts
    15
    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 hello.pl script in the cgi-bin and made it executable. I tried to access it from localhost and still got the same error.

  4. #14
    Just Joined!
    Join Date
    Sep 2012
    Posts
    15
    actually the localhost/cgi-bin/hello.pl script did work i had typed in my browser wrong, but It worked i got:


    Hello from /usr/lib/cgi-bin/hello.pl

  5. #15
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by killa_cam View Post
    actually the localhost/cgi-bin/hello.pl script did work i had typed in my browser wrong, but It worked i got:


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

    so try this:
    Code:
    cd /tmp
    wget http://zackgrossbart.com/hackito/bsamples/search.py.zip
    unzip search.py.zip
    cd search.py
    python search.py > 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:

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

  6. #16
    Just Joined!
    Join Date
    Sep 2012
    Posts
    15
    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

  7. #17
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    after you ran this command:
    Code:
    python search.py > 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?

  8. #18
    Just Joined!
    Join Date
    Sep 2012
    Posts
    15
    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

  9. #19
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    okay, so i guess it only wants scripts in that dir. try this:

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

    Code:
    http://localhost/search/Search.html

  10. #20
    Just Joined!
    Join Date
    Sep 2012
    Posts
    15
    After entering the commands and trying to access localhost/search/search.html



    The requested URL /search/cgi-bin/search.py 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/search.py" method="POST">

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

Page 2 of 3 FirstFirst 1 2 3 LastLast

Posting Permissions

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