Revisit: perl CGIs with suphp

Discussion in 'Installation/Configuration' started by zetnsh, Jan 18, 2008.

  1. zetnsh

    zetnsh New Member

    Hi there,

    I was looking for the answer months ago, never found it, and it was never really an issue then :)

    I have successfully installed suphp with ISPConfig which works fine, PHP scripts run as the website user rather than apache user, but I always came unstuck getting it to run CGI's -I just don't know where to start with the apache config etc.

    Here is /etc/suphp.conf:
    Code:
    [global]
    ;Path to logfile
    logfile=/var/log/httpd/suphp_log
    ;Loglevel
    loglevel=info
    ;User Apache is running as
    webserver_user=apache
    ;Path all scripts have to be in
    docroot=/
    ;Path to chroot() to before executing script
    ;chroot=/mychroot
    ;Security options
    allow_file_group_writeable=true
    allow_file_others_writeable=false
    allow_directory_group_writeable=true
    allow_directory_others_writeable=false
    ;Check wheter script is within DOCUMENT_ROOT
    check_vhost_docroot=true
    ;Send minor error messages to browser
    errors_to_browser=false
    ;PATH environment variable
    env_path=/bin:/usr/bin
    ;Umask to set, specify in octal notation
    Here is /etc/httpd/conf.d/suphp.conf:

    Code:
    LoadModule suphp_module modules/mod_suphp.so
    And finally attached as a .txt file is httpd.conf (overkill probably - I know!)

    Any thoughts would be much appreciated!

    Neil
     

    Attached Files:

  2. Hans

    Hans Moderator Moderator

    Did you enable "CGI Scripts" and/or "Standard CGI Scripts"
    on the basis tab within ISPConfig for that website?

    The cgi-scripts must be placed within the folder "cgi-bin" or "bin" within the webspace of your website.
     
  3. zetnsh

    zetnsh New Member

    Hi Hans, thanks for responding!

    Yes, CGI Scripts was ticked.

    The CGI scripts are in a folder called cgi-bin on the same level as the web directory for that user. They all work fine, it's just they don't run as the user of the web!

    I've just run this perl test script:

    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n$< $>\n";
    This tells me the user the script is running as (and in fact the user it would be running as if it was setuid which it isn't).

    This comes back with

    Code:
    48   48
    which is the uid of the apache user on my system.

    Any other thoughts anyone?

    Thanks,

    Neil
     
  4. Hans

    Hans Moderator Moderator

    Did you create an admin user for that website?
    If you have created an admin user for that website, your cgi scripts should run automaticly under that admin user.
     
  5. zetnsh

    zetnsh New Member

    Bear in mind this is perl not php (did I explain that?). The PHP side is working correctly, it's just Perl CGI's that are the problem.

    Yes, there is an admin user set up, the same one that owns the files!

    Any thoughts?

    Thanks,

    Neil
     
  6. Hans

    Hans Moderator Moderator

  7. zetnsh

    zetnsh New Member

    Just to confirm on this, here is my test CGI program written in perl:

    Code:
    [root@historydirect cgi-bin]# ls -al /var/www/web1/cgi-bin/testperm.cgi
    -rwxr-xr-x 1 web1_historydirect web1 59 Jan 18 16:01 /var/www/web1/cgi-bin/testperm.cgi
    That seems to look right with what you told me...

    Thanks again,

    Neil
     

Share This Page