CGI - Apache - Vhost - Suexec ???

Alles, was den Apache betrifft, kann hier besprochen werden.

CGI - Apache - Vhost - Suexec ???

Postby Thomas27 » 13. September 2004 10:04

Hallo ich habe mich den ganzen Tag durchs Netz gewühlt und alle möglichen Tipps probiert, wie ich CGI Scripte mit den oben aufgeführten Paketen zum laufen bringe.

hier erst einmal das Test Script:

Code:
Code: Select all
#!/usr/bin/perl -w

use CGI qw/:standard/;
##################################################  #############
print header(),                            # CGI-Header
                                           # Startsequenz
      start_html('-title'   => "CGI Dump", #   und Titel
                 '-bgcolor' => "white"),   # Hintergrundfarbe
      h2("Query Parameters:"),             # H2-Überschrift
      CGI::as_string(),           # CGI-Parameter formatiert
      h2("Environment:"),         # H2-Überschrift
                                  # Environment ausgeben
      (map { p("$_ => $ENV{$_}") } sort keys %ENV),
      end_html();                 # Abschluß
##################################################  ##### EOF ###


Das Script wurde mit dem Windows Notepad erstellt, als ANSI File abgespeichert und auch als ASCII upgeloadet. Danach bekomme ich den Fehler 500 Internal Server Error.

im suexec_log file steht dann folgendes:

Code:
Code: Select all
emerg: cannot get docroot information (/var/www)
info: (target/actual) uid: (web8/web8) gid: (ftponly/ftponly) cmd: test.cgi


meine Vermutung ist, dass das docroot eventl. falsch ist.
Die Seite von der das Script aufgerufen wird liegt unter opt/web8/html/cgi-bin

Ich hoffe diese Informationen reichen aus, falls nicht sagt bescheid, dann poste ich noch die httpd usw.

Code:
Code: Select all
suexec -V
 -D DOC_ROOT="/var/www"
 -D GID_MID=48
 -D HTTPD_USER="wwwrun"
 -D LOG_EXEC="/var/log/httpd/suexec_log"
 -D SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
 -D UID_MID=48
 -D USERDIR_SUFFIX="public_html"


kurze Frage:
was genau liegt alles im docroot, bzw. auf was bezieht sich dieses Verzeichnis?
Last edited by Thomas27 on 13. September 2004 17:41, edited 1 time in total.
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby CubaLibre » 13. September 2004 17:23

Als ASCII hochladen und chmod 755 setzen.
CubaLibre
 
Posts: 25
Joined: 18. January 2004 01:35
Location: Weilburg

Postby Thomas27 » 13. September 2004 17:45

habe ich gemacht, alle Ordner und Dateien aben die Rechte 755
und das File wurde als ASCII hochgeladen

ich denke das ganze Problem liegt wirklich an der Server Konfiguration
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby CubaLibre » 13. September 2004 18:18

Ah hab gerade was entdeckt: Dein User dir stimmt nicht. Ist noch auf public_html gesetzt welches als default Wert steht. Soweit ich weiß funktioniert das im vhost nicht.

Eine gute Beschreibung findest du hier!
CubaLibre
 
Posts: 25
Joined: 18. January 2004 01:35
Location: Weilburg

Postby Thomas27 » 14. September 2004 10:12

Code: Select all
Hierarchy limitations
For security and efficiency reasons, all suEXEC requests must remain within either a top-level document root for virtual host requests, or one top-level personal document root for userdir requests. For example, if you have four VirtualHosts configured, you would need to structure all of your VHosts' document roots off of one main Apache document hierarchy to take advantage of suEXEC for VirtualHosts. (Example forthcoming.)


Ich habe mir den ganzen Text durchgelesen, muss aber sagen, dass er nicht für Linux Neulinge geeignet ist. Aber ich denke wir sind dem Fehler auf der Spur. Ich muss in den VHost Configurationen einen User Path angeben.

der CGI-Bin Path ist bei allen Kunden gleich also: /opt/kundexy/html/cgi-bin/

Ich bin mir aber nicht sicher ob der Author dies meint. Als Beispiel hier eine vhost Konfiguration:

Code: Select all
<VirtualHost 00.000.000.00:80>
ServerName wexxx.xxxx.de
ServerAlias  xxxx.de www.xxx.de
DocumentRoot /opt/webx/html
User webx
Group ftponly
ScriptAlias /cgi-bin/ /opt/webx/html/cgi-bin/
php_admin_value open_basedir /opt/webx/
php_admin_value upload_tmp_dir /opt/webx/phptmp/
DirectoryIndex index.php index.php3 DirectoryIndex index.php index.php3 index.html index.shtml index.php4 index.phtml
php_admin_value include_path .:/opt/webx/html
php_admin_value safe_mode on
php_admin_value upload_max_filesize 9M
php_admin_value post_max_size 9M
php_admin_value max_execution_time 3600
php_admin_value max_input_time 3600
php_admin_value memory_limit 10M
php_admin_value session.save_path /opt/webx/phptmp/
</VirtualHost>
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby Thomas27 » 15. September 2004 09:11

Hier noch meine Konfigurations Files

confixx_vhost.conf
Code: Select all
<VirtualHost 00.000.000.00:80>
ServerName webx.xxx.de
ServerAlias xxx.de www.xxx.de
DocumentRoot /opt/webxy/html
User webxy
Group ftponly
ScriptAlias /cgi-bin/ /opt/webxy/html/cgi-bin/
php_admin_value open_basedir /opt/webxy/
php_admin_value upload_tmp_dir /opt/webxy/phptmp/
DirectoryIndex index.php index.php3 DirectoryIndex index.php index.php3 index.html index.shtml index.php4 index.phtml
php_admin_value include_path .:/opt/webxy/html
php_admin_value safe_mode on
php_admin_value upload_max_filesize 9M
php_admin_value post_max_size 9M
php_admin_value max_execution_time 3600
php_admin_value max_input_time 3600
php_admin_value memory_limit 10M
php_admin_value session.save_path /opt/webxy/phptmp/
</VirtualHost>


httpf.conf
Code: Select all
#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
<IfModule mod_alias.c>

    #
    # Note that if you include a trailing / on fakename then the server will
    # require it to be present in the URL.  So "/icons" isn't aliased in this
    # example, only "/icons/".  If the fakename is slash-terminated, then the
    # realname must also be slash terminated, and if the fakename omits the
    # trailing slash, the realname must also omit it.
    #
    Alias /icons/ "/usr/local/httpd/icons/"

    <Directory "/usr/local/httpd/icons">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    # This Alias will project the on-line documentation tree under /manual/
    # even if you change the DocumentRoot. Comment it if you don't want to
    # provide access to the on-line documentation.
    #
    Alias /manual/ "/usr/local/httpd/htdocs/manual/"

    <Directory "/usr/local/httpd/htdocs/manual">
        Options Indexes FollowSymlinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the realname directory are treated as applications and
    # run by the server when requested rather than as documents sent to the client.
    # The same rules about trailing "/" apply to ScriptAlias directives as to
    # Alias.
    #
    ScriptAlias /cgi-bin/ "/usr/local/httpd/cgi-bin/"

<IfModule mod_perl.c>
    # Provide two aliases to the same cgi-bin directory,
    # to see the effects of the 2 different mod_perl modes.
    # for Apache::Registry Mode
    ScriptAlias /perl/          "/usr/local/httpd/cgi-bin/"
    # for Apache::Perlrun Mode
    ScriptAlias /cgi-perl/      "/usr/local/httpd/cgi-bin/"
</IfModule>
    #
    # "/usr/local/httpd/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "/usr/local/httpd/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

</IfModule>
# End of aliases.


#
# set /cgi-bin for CGI execution
#
<Location /cgi-bin>
AllowOverride None
Options +ExecCGI -Includes
SetHandler cgi-script
</Location>

#
# If mod_perl is activated, load configuration information
#
<IfModule mod_perl.c>
Perlrequire /usr/include/apache/modules/perl/startup.perl
PerlModule Apache::Registry

#
# set Apache::Registry Mode for /perl Alias
#
<Location /perl>
SetHandler  perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader On
</Location>

#
# set Apache::PerlRun Mode for /cgi-perl Alias
#
<Location /cgi-perl>
SetHandler  perl-script
#
# set Apache::PerlRun Mode for /cgi-perl Alias
#
<Location /cgi-perl>
SetHandler  perl-script
PerlHandler Apache::PerlRun
Options ExecCGI
PerlSendHeader On
</Location>

</IfModule>



ich muss aber dazusagen, dass ich Linux Neuling bin, falls du also eine Lösung für mein Problem hast, etwas ausführlicher darauf eingehen, was ich tun muss, um meine CGI - Scripte zum laufen zu bringen
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby CubaLibre » 15. September 2004 10:32

Ich würde die vhost.conf so schreiben:

Code: Select all
NameVirtualHost 00.00.00.00:80
php_admin_flag safe_mode On
php_admin_value safe_mode_exec_dir /opt/webxy/empty
php_admin_value open_basedir /opt/webxy/
php_admin_value upload_tmp_dir /opt/webxy/phptmp/
php_admin_value upload_max_filesize 9M
php_admin_value post_max_size 9M
php_admin_value max_execution_time 3600
php_admin_value max_input_time 3600
php_admin_value memory_limit 10M
php_admin_value session.save_path /opt/webxy/phptmp/

UseCanonicalName Off
LogFormat "%V:#%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx

LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx2

<Directory "/opt/webxy">
AllowOverride All
AllowOverride Indexes
Otions None
Options -FollowSymLinks -SymLinksIfOwnerMatch +Includes
</Directory>

<VirtualHost 00.000.000.00:80>
ServerName webx.xxx.de
ServerAlias www.xxx.de server.xxx.de
DocumentRoot /opt/webxy/html
User webxy
Group ftponly
</VirtualHost>


..und setze mal den letzten Part der httpd.conf so:
Code: Select all

<Location /cgi-perl>
SetHandler  perl-script
PerlHandler Apache::Regitry
Options ExecCGI
PerlSendHeader On
</Location>


Ich hoffe ich habe nichts übersehen.
CubaLibre
 
Posts: 25
Joined: 18. January 2004 01:35
Location: Weilburg

Postby Thomas27 » 15. September 2004 11:23

ich bekomme mit dieser Konfiguration folgende Fehlermeldungen.
ich habe den Apache neu gestartet.

error_log
Code: Select all
[Wed Sep 15 12:02:02 2004] [warn] NameVirtualHost 83.133.119.47:80 has no VirtualHosts
[Wed Sep 15 12:02:03 2004] [notice] Apache/1.3.23 (Unix) mod_python/2.7.8 Python/2.2 PHP/4.3.0 mod_perl/1.26 configured -- resuming normal operations
[Wed Sep 15 12:02:03 2004] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Sep 15 12:02:03 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)

[Wed Sep 15 12:03:26 2004] [error] [client 80.140.131.207] Premature end of script headers: /opt/web8/html/cgi-bin/test.cgi


suexec_log
Code: Select all
[2004-09-15 12:03:26]: info: (target/actual) uid: (web8/web8) gid: (ftponly/ftponly) cmd: test.cgi
[2004-09-15 12:03:26]: emerg: cannot get docroot information (/var/www)


aktuelle Konfiguration der confixx_vhost_conf:
Code: Select all
   ### created Sat Aug 28 16:20:01 2004 ###

NameVirtualHost 83.133.119.47:80
php_admin_flag safe_mode On
php_admin_value safe_mode_exec_dir /opt/empty

UseCanonicalName Off
LogFormat "%V:#:%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx
LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx2
CustomLog |/root/confixx/pipelog.pl confixx
<Directory "/opt">
<Files ~ "^\.ht">
deny from all
</Files>
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Options None
Options -FollowSymLinks -SymLinksIfOwnerMatch +Includes
</Directory>


<VirtualHost 83.133.119.47:80>
DocumentRoot /opt//confixx/html/gesperrt
</VirtualHost>
<VirtualHost 83.133.119.47:80>
ServerName xxx.de
ServerAlias  xxx.de www.xxx.de
DocumentRoot /opt/web8/html
User web8
Group ftponly
ScriptAlias /cgi-bin/ /opt/web8/html/cgi-bin/
php_admin_value open_basedir /opt/web8/
php_admin_value upload_tmp_dir /opt/web8/phptmp/
DirectoryIndex index.php index.php3 DirectoryIndex index.php index.php3 index.html index.shtml index.php4 index.phtml
php_admin_value include_path .:/opt/web8/html

php_admin_flag safe_mode On

php_admin_value safe_mode on

php_admin_value safe_mode_exec_dir /opt/web8/html/cgi-bin/

php_admin_value upload_max_filesize 9M
php_admin_value post_max_size 9M
php_admin_value max_execution_time 3600
php_admin_value max_input_time 3600
php_admin_value memory_limit 10M
php_admin_value session.save_path /opt/web8/phptmp/

UseCanonicalName Off
LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx2

<Directory "/opt/web8">
AllowOverride All
AllowOverride Indexes
Options None
Options -FollowSymLinks -SymLinksIfOwnerMatch +Includes
</Directory>
</VirtualHost>


aktuelle httpd_conf
Code: Select all

#
# set Apache::PerlRun Mode for /cgi-perl Alias
#
<Location /cgi-perl>
SetHandler  perl-script
PerlHandler Apache::Regitry
Options ExecCGI
PerlSendHeader On
</Location>

Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby CubaLibre » 15. September 2004 11:36

Hi

1. Premature end of script headers bedeutet, daß dein Perlscript fehlerhaft ist! Wenn du z.B. print "Content-type:text/html"; solltest du Umbrüche einbauen : print "Content-type:text/html\n\n";

2. Du hast in der vhost.conf unter DocumentRoot ein Slash zu viel.

3. Nimm mal die erste Zeile (NameVirtualHost...)wieder raus.


Sonst sehe ich nur Infos, keine Fehler.
CubaLibre
 
Posts: 25
Joined: 18. January 2004 01:35
Location: Weilburg

Postby Thomas27 » 15. September 2004 11:43

ok, dass habe ich am Anfang auch gedacht, aber wenn ich folgendes mache

Code: Select all
login:/opt/web8/html/cgi-bin # perl test.cgi
Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
        "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head><title>CGI Dump</title>
</head><body bgcolor="white"><h2>Query Parameters:</h2><UL></UL><h2>Environment:</h2><p>COLORTERM => 1</p><p>CPU => i686</p><p>HOME => /root</p><p>HOST => login</p><p>HOSTNAME => login.0911server.de</p><p>HOSTTYPE => i386</p><p>INFODIR => /usr/local/info:/usr/share/info:/usr/info</p><p>INFOPATH => /usr/local/info:/usr/share/info:/usr/info</p><p>INPUTRC => /etc/inputrc</p><p>LESS => -M -I</p><p>LESSCLOSE => lessclose.sh %s %s</p><p>LESSKEY => /etc/lesskey.bin</p><p>LESSOPEN => lessopen.sh %s</p><p>LESS_ADVANCED_PREPROCESSOR => no</p><p>LOGNAME => root</p><p>LS_COLORS => no=00:fi=00:di=01;34:ln=01:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;31:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tbz2=00;31:*.png=01;35:*.bmp=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.pcx=01;35:*.ppm=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.wav=00;32:*.mp3=00;32:*.au=00;32:*.aiff=00;32:*.mid=00;32:*.voc=00;32:</p><p>LS_OPTIONS => -a -N --color=tty -T 0</p><p>MACHTYPE => i686-suse-linux</p><p>MAIL => /var/mail/root</p><p>MANPATH => /usr/share/man:/usr/local/man:/usr/X11R6/man</p><p>MINICOM => -c on</p><p>OLDPWD => /opt/web8/html</p><p>OSTYPE => linux</p><p>PAGER => less</p><p>PATH => /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin</p><p>PWD => /opt/web8/html/cgi-bin</p><p>SHELL => /bin/bash</p><p>SHLVL => 1</p><p>SSH_TTY => /dev/pts/1</p><p>TERM => xterm</p><p>TEXINPUTS => :/root/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX</p><p>USER => root</p><p>XKEYSYMDB => /usr/X11R6/lib/X11/XKeysymDB</p><p>XNLSPATH => /usr/X11R6/lib/X11/nls</p><p>_ => /usr/bin/perl</p><p>_SUSECONFIG_PROFILE => true</p><p>mc => () {  mkdir -p $HOME/.mc/tmp 2>/dev/null;
 chmod 700 $HOME/.mc/tmp;
 MC=$HOME/.mc/tmp/mc-$$;
 /usr/bin/mc -P "$@" >"$MC";
 cd "`cat $MC`";
 rm -f "$MC";
 unset MC
}</p></body></html>


Dann wird das Script doch korrekt ausgeführt oder?
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby CubaLibre » 15. September 2004 11:45

Nein..

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

..so müßte es gehen.
CubaLibre
 
Posts: 25
Joined: 18. January 2004 01:35
Location: Weilburg

Postby Thomas27 » 15. September 2004 12:06

geht nach wie vor nicht, aber die Fehlermeldungen vom Apache sind immerhin nicht mehr vorhanden.

Das mit dem Script habe ich schon einmal probiert, da ich mich schon durch etliche Foren geschlagen habe. Aber ich habe es jetzt auf jedenfall eingefügt:

Code: Select all
#!/usr/bin/perl -w

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

use CGI qw/:standard/;
###############################################################
print header(),                            # CGI-Header
                                           # Startsequenz
      start_html('-title'   => "CGI Dump", #   und Titel
                 '-bgcolor' => "white"),   # Hintergrundfarbe
      h2("Query Parameters:"),             # H2-Überschrift
      CGI::as_string(),           # CGI-Parameter formatiert
      h2("Environment:"),         # H2-Überschrift
                                  # Environment ausgeben
      (map { p("$_ => $ENV{$_}") } sort keys %ENV),
      end_html();                 # Abschluß
####################################################### EOF ###
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56

Postby Thomas27 » 15. September 2004 12:42

:D
Habe da Problem gelöst.

mit diesem einfachen Befehl
Code: Select all
ln -s /opt /var/www ln -s /opt /var/www


Da suexec einen andern Doc_Root enthält, biegt der obere Befehl den Pfad einfach um.

Code: Select all
suexec -V
 -D DOC_ROOT="/var/www"


Ich bedanke mich trotzdem für die ganzen Denkanstöße!
Thomas27
 
Posts: 18
Joined: 13. September 2004 09:56


Return to Apache

Who is online

Users browsing this forum: No registered users and 23 guests