ubuntuusers.de

Apache führt keine Perl Skripte aus sondern bietet diese zum Download an

Status: Gelöst | Ubuntu-Version: Server 14.04 (Trusty Tahr)
Antworten |

AuX

Avatar von AuX

Anmeldungsdatum:
4. Januar 2013

Beiträge: 28

Wohnort: Berlin

Hallo,

eventuel ist ein User hier gewillt mir zu helfen und kann dieses Problem beheben

frische Installation:

apache2 mariadb-server mariadb-client php5 php5-mysql libapache2-mod-php5 libapache2-mod-perl2 phpmyadmin
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
root@TIKAL:/etc/apache2# cat sites-available/000-default.conf 
<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html
	ServerName tikal.fritz.box
	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn



ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
#ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#<Directory "/usr/lib/cgi-bin">
#Options All
#AllowOverride All
#Require all granted
#</Directory>


	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Wie hier zu sehen ist, habe ich schon an den Einstellungen geschraubt, allerdings jedes Mal ohne Erfolg.

1
2
3
4
root@TIKAL:/etc/apache2# cat /usr/lib/cgi-bin/test.pl 
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hallo Welt!\n";

Die Berechtigungen sind

1
2
root@TIKAL:/etc/apache2# ls -l /usr/lib/cgi-bin/test.pl
-rw-r--r-- 1 root root 78 Jul 26 11:45 /usr/lib/cgi-bin/test.pl

Ich denke aber nicht, dass es an den Berechtigungen liegt. Denn ich habe im gleichen Ordner - um den Alias zu testen - ein PHP-Skript angelegt, welches die gleichen Rechte besitzt und wunderbar funktioniert:

1
2
3
4
5
6
root@TIKAL:/etc/apache2# ls -l /usr/lib/cgi-bin/testephp.php
-rw-r--r-- 1 root root 20 Jul 26 11:47 /usr/lib/cgi-bin/testephp.php
root@TIKAL:/etc/apache2# cat /usr/lib/cgi-bin/testephp.php
<?php
phpinfo();
?>

Wenn ich nun im Webbrowser meiner Wahl tikal.fritz.box/cgi-bin/testephp.php eingebe sehe ich die PHP-Testseite. Ein wget-Aufruf lädt die HTML-Daten runter. Alles gut also. Gehe ich aber auf tikal.fritz.box/cgi-bin/test.pl, bietet er mir die test.pl zum Download an, anstatt sie auszuführen. Würde mich sehr freuen wenn mir jemand helfen mag oder sagen kann wo mein Problem liegt - ich bin leider gerade Blind. ☹

Vielen Dank!

Dakuan

Avatar von Dakuan

Anmeldungsdatum:
2. November 2004

Beiträge: 6519

Wohnort: Hamburg

Mit Apache habe ich lange nichts mehr gemacht, aber ich erinnere mich, das man das CGI Modul erst aktivieren muss. Das ist etwas anderes als das PHP Modul.

xabbuh Team-Icon

Anmeldungsdatum:
25. Mai 2006

Beiträge: 6411

Gib dem Perl-Skript mal die Rechte zum Ausführen.

AuX

(Themenstarter)
Avatar von AuX

Anmeldungsdatum:
4. Januar 2013

Beiträge: 28

Wohnort: Berlin

Ihr Lieben! Vielen Dank!! ☺

Es funktioniert nun und war eine Lösung aus beiden Posts. Auch wenn ich zuvor schon mit a+x experimentiert habe - so wie man dies in vielen Foren liest - hätte mir dies nichts gebracht, solange das Modul eben nicht ausgeführt wird. Deshalb hier der Lösungsweg für alle denen es auch so geht - damit ihr nicht ewig Research betreiben müsst.

Dakuan schrieb:

Mit Apache habe ich lange nichts mehr gemacht, aber ich erinnere mich, das man das CGI Modul erst aktivieren muss. Das ist etwas anderes als das PHP Modul.

Richtig. Die Module müssen korrekt geladen werden. Man kann sich alle aktiven Module durch apachectl -M anschauen. Mittels grep guckt man dann ob die passenden Module für diesen Test geladen sind:

1
2
3
4
root@TIKAL:/usr/lib/cgi-bin# apachectl -M | grep "perl"
 perl_module (shared)
root@TIKAL:/usr/lib/cgi-bin# apachectl -M | grep "cgi"
 cgi_module (shared)

Ist dies nicht der Fall, wählt man sich aus der Liste der Apache Module:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
root@TIKAL:/usr/lib/cgi-bin# ls /etc/apache2/mods-available/
access_compat.load  authn_file.load       cache_disk.load     deflate.load       include.load              mime.load         proxy_ajp.load       proxy_wstunnel.load  setenvif.load          userdir.conf
actions.conf        authn_socache.load    cache.load          dialup.load        info.conf                 mime_magic.conf   proxy_balancer.conf  ratelimit.load       slotmem_plain.load     userdir.load
actions.load        authnz_ldap.load      cache_socache.load  dir.conf           info.load                 mime_magic.load   proxy_balancer.load  reflector.load       slotmem_shm.load       usertrack.load
alias.conf          authz_core.load       cgid.conf           dir.load           lbmethod_bybusyness.load  mpm_event.conf    proxy.conf           remoteip.load        socache_dbm.load       vhost_alias.load
alias.load          authz_dbd.load        cgid.load           dump_io.load       lbmethod_byrequests.load  mpm_event.load    proxy_connect.load   reqtimeout.conf      socache_memcache.load  xml2enc.load
allowmethods.load   authz_dbm.load        cgi.load            echo.load          lbmethod_bytraffic.load   mpm_prefork.conf  proxy_express.load   reqtimeout.load      socache_shmcb.load
asis.load           authz_groupfile.load  charset_lite.load   env.load           lbmethod_heartbeat.load   mpm_prefork.load  proxy_fcgi.load      request.load         speling.load
auth_basic.load     authz_host.load       data.load           expires.load       ldap.conf                 mpm_worker.conf   proxy_fdpass.load    rewrite.load         ssl.conf
auth_digest.load    authz_owner.load      dav_fs.conf         ext_filter.load    ldap.load                 mpm_worker.load   proxy_ftp.conf       sed.load             ssl.load
auth_form.load      authz_user.load       dav_fs.load         file_cache.load    log_debug.load            negotiation.conf  proxy_ftp.load       session_cookie.load  status.conf
authn_anon.load     autoindex.conf        dav.load            filter.load        log_forensic.load         negotiation.load  proxy_html.load      session_crypto.load  status.load
authn_core.load     autoindex.load        dav_lock.load       headers.load       lua.load                  perl.load         proxy_http.load      session_dbd.load     substitute.load
authn_dbd.load      buffer.load           dbd.load            heartbeat.load     macro.load                php5.conf         proxy.load           session.load         suexec.load
authn_dbm.load      cache_disk.conf       deflate.conf        heartmonitor.load  mime.conf                 php5.load         proxy_scgi.load      setenvif.conf        unique_id.load

Die passenden Module aus und aktiviert diese mittels a2enmod MOD_NAME Bsp:

1
a2enmod cgi.load

Zusätzlich muss der richtige ScriptAlias (In meinem Beispiel) /etc/apache2/sites-available/000-default.conf gesetzt sein:

1
2
3
4
5
6
7
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Options FollowSymLinks
Require all granted
</Directory>

Zusätzlich kommt dann die Tatsache, dass die *.CGI oder *.PL Scripte ausführbar gemacht werden müssen

xabbuh schrieb:

Gib dem Perl-Skript mal die Rechte zum Ausführen.

Dies geschieht (z.B.) mittels:

1
2
3
4
5
root@TIKAL:/usr/lib/cgi-bin# ls -l test2.pl 
-rw-r--r-- 1 root root 165 Jul 26 00:59 test2.pl
root@TIKAL:/usr/lib/cgi-bin# chmod a+x test2.pl 
root@TIKAL:/usr/lib/cgi-bin# ls -l test2.pl 
-rwxr-xr-x 1 root root 165 Jul 26 00:59 test2.pl

Vielen Dank für eure Hilfe und ich hoffe der Beitrag hier kann anderen auch noch helfen!

Beste Grüße, AuX

Gutschy

Anmeldungsdatum:
26. November 2006

Beiträge: 50

Hi Aux, du hast mir den Tag gerettet. Vielen Dank!!! 👍

bernd1

Avatar von bernd1

Anmeldungsdatum:
9. April 2006

Beiträge: 234

Wohnort: Saarbrücken

Mann Aux, vielen, vielen Dank - Du hast mir nicht nur den Tag, sondern mindestens eine Woche gerettet, Danke ☺

Antworten |