The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cgi problem

Discussion in 'General Discussion' started by Secret Agent, Jul 5, 2005.

  1. Secret Agent

    Secret Agent Guest

    This is the cgi script that won't work (located in cgi-bin dir)

    #!/usr/bin/perl
    use CGI;
    $query = new CGI;
    $link = "";
    $link = $query -> param('purchase');
    if ($link eq "") {$link="http://www.domain.com/error.shtml";};
    print "Location: $link\n\n";


    What could be the problem? It was working fine a few days ago. I removed .htaccess file as well.

    It is chmodded 755 as well
     
  2. kekays

    kekays Active Member

    Joined:
    Nov 2, 2004
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    gimme the error meaasge
     
  3. Secret Agent

    Secret Agent Guest

    page not found :)
     
  4. kekays

    kekays Active Member

    Joined:
    Nov 2, 2004
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    chown username:username filename
    chmod +x filename
     
  5. Secret Agent

    Secret Agent Guest

    Is this correct?


    root@server2 [/home/begemot2/public_html/cgi-bin]# chown begemot2:begemot2 purchase.pl
    root@server2 [/home/begemot2/public_html/cgi-bin]# chmod +x purchase.pl
    root@server2 [/home/begemot2/public_html/cgi-bin]#
    root@server2 [/home/begemot2/public_html/cgi-bin]#


    Still get page not found
     
  6. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Is the ScriptAlias missing from the virtualhost container for the domain in httpd.conf?
     
  7. kekays

    kekays Active Member

    Joined:
    Nov 2, 2004
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    It seems like page permission error please check out parent folder permission.
     
  8. linux-image

    linux-image Well-Known Member

    Joined:
    Jun 8, 2004
    Messages:
    1,192
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    Root Administrator
    create a page; test.pl

    ============================================
    #!/usr/bin/perl

    print "Content-type: text/html\n\n";
    print "<HTML><HEAD>";
    print "<TITLE>CGI Test</TITLE>";
    print "</HEAD>";
    print "<BODY><H2>I just wrote a web page using Perl!</H2>";
    print "</BODY></HTML>";
    ==============================================

    chown and make the file 755, and then try. If this also gives a page not found, probably an issue with the ScripAlias at the httpd else an error with the script u did.
     
  9. Secret Agent

    Secret Agent Guest

    This is httpd.conf portion

    <VirtualHost xxx.202.65.106>
    ServerAlias domain.com
    ServerAdmin webmaster@domain.com
    DocumentRoot /home/begemot2/public_html
    BytesLog domlogs/domain.com-bytes_log
    <IfModule mod_userdir.c>
    UserDir disabled
    UserDir enabled begemot2
    </IfModule>
    <IfModule mod_php4.c>
    php_admin_value open_basedir "/home/begemot2/:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    User begemot2
    Group begemot2
    ServerName www.domain.com

    <IfModule mod_userdir.c>
    Userdir disabled
    Userdir enabled begemot2
    </IfModule>


    User begemot2
    Group begemot2
    CustomLog /usr/local/apache/domlogs/domain.com combined
    ScriptAlias /cgi-bin/ /home/begemot2/public_html/begemot2/cgi-bin/
    </VirtualHost>


    ScriptAlias was missing so I added the line above, restarted Apache, still page not found 404 error

    chown begemot:begemot purchase.pl
    chown 755 purchase.pl

    Same problem
     
  10. Secret Agent

    Secret Agent Guest

    Test script doesn't work either
     
  11. linux-image

    linux-image Well-Known Member

    Joined:
    Jun 8, 2004
    Messages:
    1,192
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    Root Administrator
    ScriptAlias /cgi-bin/ /home/begemot2/public_html/begemot2/cgi-bin/

    this is the error.make it to

    ScriptAlias /cgi-bin/ /home/begemot2/public_html/cgi-bin/

    restart httpd. then try
     
  12. Secret Agent

    Secret Agent Guest

    That fixed it but many entries in httpd.conf have no ScriptAlias
    or in this format

    ScriptAlias /cgi-bin/ /home/antro/public_html/splatmedia/cgi-bin/


    I ran /scripts/rebuildhttpdconf

    That didn't fix it.

    Any ideas why?

    This is after a server move as well
     
  13. linux-image

    linux-image Well-Known Member

    Joined:
    Jun 8, 2004
    Messages:
    1,192
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    Root Administrator
    coz it dosent check the ScriptAlias.
     
  14. rootuser

    rootuser Well-Known Member

    Joined:
    Jan 31, 2005
    Messages:
    124
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    ***INDIA***
    Same problem here


    This is my virtual host container
    <VirtualHost ip>
    ServerAlias www.domaincom
    ServerAdmin webmaster@domain.com
    DocumentRoot /home/domain/public_html
    BytesLog domlogs/domain-bytes_log
    User domain
    Group domain
    <IfModule mod_php4.c>
    php_admin_value open_basedir "/home/domain/:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    <IfModule mod_userdir.c>
    UserDir disabled
    UserDir enabled domain
    </IfModule>
    ServerName domain.com
    ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/
    User domain
    Group domain
    CustomLog domlogs/domain combined
    </VirtualHost>

    This is the perl script

    #!/usr/bin/perl -w

    print "Content-type: text/html\n\n";

    print "Hello!";
    exit;

    ~
    ~
    ~
    ~
    ~

    Running fine from command line

    perl -c hello.pl

    hello.pl syntax OK

    If i try to open it from browser getting internal server error

    Permissions are correct(755)

    in http erroe log getting errors like

    Premature end of script headers


    Any idea please
     
  15. rootuser

    rootuser Well-Known Member

    Joined:
    Jan 31, 2005
    Messages:
    124
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    ***INDIA***
    Please any one know this ..Thanks in advance.
     
  16. mgdoyle

    mgdoyle Member
    PartnerNOC

    Joined:
    Apr 24, 2004
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    If you have suexec enabled, check the logs at /usr/local/apache/logs/suexec_log for more detailed error messages on the scripts. I just migrated accounts to a new server and was getting "premature end of script headers" on all Perl scripts. It turned out the users had the permissions set to 777, which suexec does not allow--it cancels the execution of the script, hence the error mesage. The log above showed me what the issue was.

    Still no idea how suexec got enabled, since it was not enabled on the old server.
     
Loading...

Share This Page