can not execute cgi-script

Discussion in 'General' started by Elfchen, Jul 23, 2008.

  1. Elfchen

    Elfchen New Member

    HTML:
    
    
    Can not execute cgi scripts in cgi-bin directory:

    Code:
    Wed Jul 23 19:38:58 2008] [error] [client ???.78.165.69] suexec policy violation: see suexec log for more details
    [Wed Jul 23 19:38:58 2008] [error] [client ???.78.165.69] Premature end of script headers: hello.cgi
    Script:

    PHP:
    cat cgi-bin/hello.cgi
    #!/usr/bin/perl

    # hello.pl -- my first perl script!

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

    print 
    "Hello, world!\n";
    Directory:

    Code:
    ls -la
    insgesamt 32
    drwxr-xr-x  8 www-data web7 4096 2008-07-14 04:00 .
    drwxr-xr-x 13 root     root 4096 2008-07-14 02:14 ..
    drwxr-xr-x  2 www-data web7 4096 2008-07-23 17:53 cgi-bin
    -rw-rw-r--  1 root     web7    0 2008-07-23 04:00 .htpasswd
    drwxr-xr-x  3 www-data web7 4096 2008-07-15 00:30 log
    drwxrwxrwx  2 www-data web7 4096 2008-07-14 02:14 phptmp
    drwxr-xr-x  2 www-data web7 4096 2008-07-14 02:14 ssl
    drwxr-xr-x  2 www-data web7 4096 2008-07-14 02:14 user
    drwxrwxr-x  7 www-data web7 4096 2008-07-23 19:37 web
    File itself:

    Code:
    -rwxr-xr-x 1 www-data   web7  117 2008-07-23 17:43 hello.cgi
    Vhost-config

    Code:
    #
    #
    #
    ######################################
    # Vhost: www.domain.tld:80
    ######################################
    #
    #
    <VirtualHost 1.2.3.4:80>
    <Directory "/var/www/web7/cgi-bin">
    Options ExecCGI
    </Directory>
    SuexecUserGroup nobody web7
    ServerName www.domain.tld:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web7/web
    ServerAlias domain.tld
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    Alias  /cgi-bin/ /var/www/web7/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    ErrorLog /var/www/web7/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Files *.php>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php3>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php4>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php5>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    php_admin_flag safe_mode Off
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Alias /error/ "/var/www/web7/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web7/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web7/user/$1/web/$3
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
      RewriteRule .* - [F]
    </IfModule>
    </VirtualHost>
    #
    #
    It makes no difference if I add or remove this in ISPConfig:

    Code:
    <Directory "/var/www/web7/cgi-bin">
    Options ExecCGI
    </Directory>
    In ISPConfig Webpanel I have activated CGI for this Vhost.

    File is set to 755.

    What do I wrong here?

    Help please. Thank you.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Please create a administrator user for the website and then chown the cgi script so that it is owned by the web admin.
     
  3. Elfchen

    Elfchen New Member

    Thank you for your very fast reply on my post.

    Can you please tell me how to create an administrator?

    I think I have to create the admin in ISPConfig "User and email" and to activate administrator. Is this correct?
    How do I find out the chown settings for this administrator then? Should I use the nix-user web7_admin:x:10004:10007:admin:/var/www/web7 then?

    The result would is:

    Code:
    -rwxr-xr-x 1 web7_admin web7  117 2008-07-23 17:42 hello.pl
    Code:
    [Wed Jul 23 20:41:49 2008] [error] [client ???.78.165.69] suexec policy violation: see suexec log for more details
    [Wed Jul 23 20:41:49 2008] [error] [client ???.78.165.69] Premature end of script headers: hello.cgi

    Thank you.
    Susi :rolleyes:
     
    Last edited: Jul 23, 2008
  4. till

    till Super Moderator Staff Member ISPConfig Developer

  5. Elfchen

    Elfchen New Member

    Think I have done in this way (see last post) - but no change - result like before - error 500

    btw. the cgi-bin directory was automatically updated to new owner by ISPConfig, too:

    Code:
    drwxr-xr-x  2 web7_admin web7 4096 2008-07-23 17:53 cgi-bin
    
     
    Last edited: Jul 23, 2008
  6. Hans

    Hans Moderator ISPConfig Developer

    "Premature end of script" errors often has to do with wrong ownership or wrong permissions.

    If the administrator of your site is web7_admin and your webnumber is web7, you can set the right settings for the script by executing:

    chown -R -v -f web7_admin:web7 scriptname

    Where scriptname is your real scritname.
    Make sure that "CGI-scripts" are allowed for the site.
     
  7. Elfchen

    Elfchen New Member

    Solved

    Thanks. This was the correct solution.

    Code:
    chown -R -v -f web7_admin:web7 hello.cgi
    Eigentümer von âhello.cgiâ in web7_admin:web7 geändert
    So the solution is quite easy:

    1. Create an admin user (ISPConfig web-settings: User & email)
    2. All rights are changed to the new admin user by ISPConfig
    3. Files where you have changed rights are not automatically changed - it need to be done manually
    4. All works!

    Thanks to both for fast reply and correct answers!

    Susi
    :D
     

Share This Page