Autor Beitrag
LINUS19
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Mo 25.12.17 21:00 
Hallo,
Ich versuche gerade ein Projekt aus dem dem Konrad Adventskalender, wo man auf dem Rasberry Pi den Webserver Apache2 und php5 installiert und dann eine LED übers Smartphone an und aus schalten kann. Die Projektdateien dafür habe ich von der Conradseite gedownloadet. Ich habe den Rasberry Pi 3 Model B und das Betriebssystem Rasbian.

Ich scheitere momentan an den Ausführungsrechten für Dateien. Hier ein Auszug aus der Anleitung, die teilweise fehlerhaft ist und für Anfänger wie mich echt nicht zu empfehlen ist:

"Schritt 3. Rechte setzen

Öffnen sie erneut das LXTerminal und wechseln sie über cd /var/www/html/tag07 in das Verzeichnis von Tag07. Geben Sie der Datei das Ausführungsrecht:

chmod a+x 07led.py

Nun müssen Sie noch erlauben, dass der Webserver dieses Script ausführen darf: Rufen Sie dafür folgenden Befehl auf:

sudo visudo

Fügen Sie dann diese Zeile ein:

www-data ALL=(ALL) NOPASSWD: /var/www/html/tag07/07led.py

Speichern Sie die Datei Strg + O und schlie?en Sie sie mit Strg+X"

Die Dateien sind in den richtigen Ordnern und ich hatte auch schon sudo chmod a+x 07led.py ausprobiert, hat aber auch keinen Unterschied gemacht.

Und dann kommt folgende Meldung:

This File MUST be edited with the 'visudo' command as root...


LG
LINUS19


Moderiert von user profile iconChristian S.: Topic aus Alle Sprachen - Alle Plattformen verschoben am Mo 25.12.2017 um 21:34
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Mo 25.12.17 23:53 
also zumindest das mit dem Rechte setzen sollte so stimmen. im Zweifelsfall schau mal mit ls -l 07led.py ob bei den Rechten das x mit dabei ist

Zitat:
This File MUST be edited with the 'visudo' command as root...
Ich gehe mal davon aus, dass die Meldung nach dem sudo visudo erscheint. Also muss da irgendwie was schief gelaufen sein. Bei mir öffnet sich da ärgerlicherweise der vim-Editor - strg-o und strg-x sind für vim die falschen Befehle, die werden bei nano verwendet - also schau mal bitte nach welcher Editor sich bei dir öffnet.

Falls das alles nichts helfen sollte - Könntest du mir mal den Link zu diesen Dateien schicken? Oder als Anhang dass ich das irgendwie nachvollziehen kann
Danke :)

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 00:32 
Wenn ich ls -l 07led.py eingebe kommt -rwxrwxrwx 1 Pi Pi 161 Mär 30 2017 07led.py
Nach diesem Sido visudo õffnet sich GNU nano 2.2.6
Die Links kann ich erst morgen schicken.
Hoffe das hilft weiter.
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 26.12.17 00:35 
Zitat:
Wenn ich ls -l 07led.py eingebe kommt -rwxrwxrwx 1 Pi Pi 161 Mär 30 2017 07led.py
Nach diesem Sido visudo õffnet sich GNU nano 2.2.6
Das sieht soweit richtig aus.
Dann warte ich halt noch die 25 min bis morgen :D

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 12:43 
Hier ist der Link:

Ich hatte die Dateiein von tag07_neu verwendet.
www.franzis.de/media...i-2017-programme.zip
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 26.12.17 15:33 
Hast du die README.pdf gelesen? da steht nämlich drin, dass du seit dem neuesten Update von debian strech php7 anstatt php5 installiert werden muss, und somit das shell_exec zu exec wird, und das sudo visudo wegfällt. Außerdem sollst du sudo adduser www-data gpio ausführen, damit der Server zugriff auf deine GPIO-Pins erhält.
Ich hab das jetzt selber alles gemacht, funktioniert aber trotzdem nicht ganz:

Nachdem ich bein index.html auf den Knopf drückte:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.10 (Raspbian) Server at localhost Port 80

der Access-log:
ausblenden Quelltext
1:
2:
::1 - - [11/Dec/2017:07:45:51 +0100] "GET /tag07_neu/ HTTP/1.1" 200 790 "-" "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.84 Safari/537.36"
::1 - - [11/Dec/2017:07:45:52 +0100] "POST /tag07_neu/index.php HTTP/1.1" 500 803 "http://localhost/tag07_neu/" "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.84 Safari/537.36"

und der Error-Log:
ausblenden Quelltext
1:
2:
[Mon Dec 11 07:45:52.974730 2017] [:error] [pid 1616] [client ::1:37682] SoftException in Application.cpp:350: UID of script "/var/www/html/tag07_neu/index.php" is smaller than min_uid, referer: http://localhost/tag07_neu/
[Mon Dec 11 07:45:52.975254 2017] [core:error] [pid 1616] [client ::1:37682] End of script output before headers: index.php, referer: http://localhost/tag07_neu/


vielleicht funktioniert es ja bei dir - probier es einfach mal aus

Edit: es funktioniert auch nicht, wenn ich direkt den Ordner tag07 bzw. tag07_neu verwende - ich hatte den vorher umbenannt

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)

Für diesen Beitrag haben gedankt: LINUS19
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 19:06 
Danke, dasit dem Readme habe ich gar nicht gesehen. Aber auf meinem Raspberry ist Debian Jessie, also betrifft mich das PDF ja nicht.Aber es funktioniert immer noch nicht.
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 26.12.17 19:09 
was passiert denn bei dir, wenn du die Seite aufrufst und den 'Knopf' drückst?

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 19:28 
Dann passiert garnichts, es kommt auch keine Fehlermeldung.
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 26.12.17 19:34 
was genau machst du dennn? Theoretisch müsstest du auf dem Raspi nur den Browser öffnen und localhost/tag07_neu aufrufen. Da müsste doch zumindest der Button zu sehen sein.

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 19:48 
Ja den Button sehe ja auch es passiert nur nichts.
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 26.12.17 19:49 
siehst du in der Konsole irgendwas?

Edit: in der Browser-Konsole: strg-i

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)


Zuletzt bearbeitet von Symbroson am Di 26.12.17 19:52, insgesamt 1-mal bearbeitet
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 19:51 
In welcher Konsole?, sorry kenne mich damit noch nicht aus.
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Di 26.12.17 20:07 
Bei den "Entwickler Tools kommt nur sowas: Navigated to "http://localhost/tag07_neu/index.php"
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 26.12.17 21:14 
Kannst du mal bitte vorsichtshalber der .py datei die Zeile print("led.py started") hinzufügen und das in der Raspi-Konsole ausführen?
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
[strg-alt-t]
$ cd /var/www/html/tag07_new
$ nano 07led.py
 -> in 2. Zeile vor das import print("led.py started") hinzufügen
[strg-o]
[strg-x]
$ python 07led.py
 -> output?

wenn sonst nirgendwo Fehlermeldungen kommen und beim Aufruf von localhost/tag07/index.php nur ne leere Seite kommt weiß ich auch nicht weiter...
Ich probier aber noch ein bisschen weiter :roll:

Ich scheitere gerade daran auf meinem Win-Rechner nen Apache-Server einzurichten - sonst muss ich dauernd Maus und Tastatur umstecken
Ich finde aber auch keine msi die mir Apache vollst. Installiert, und die meisten Beschreibungen sind für linux.
von MinGW hab ich eine Art Linux-Konsole, aber da kommt bei mir bein ./configure ein Syntax-Fehler in Zeile 2021 der configure Datei
Also Windows macht es einem manchmal echt nicht leicht... ein Hoch auf Paketmanager

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Mi 27.12.17 00:13 
Wenn ich das mit dem Print("led.py stardet") einfüge und in der Konsole ausführe, wird der Text ausgegeben und die LED leuchtet für ca. 1s auf.(vorher war sie die ganze Zeit aus)


Du hättest ja gesagt:

wenn sonst nirgendwo Fehlermeldungen kommen und beim Aufruf von localhost/tag07/index.php nur ne leere Seite kommt...

Ich sehe aber den Button beim Aufruf der Seite. Es muss denke ich am Webserver liegen weil die LED beim Ausführen von der LED.py Datei ja einmal aufleuchtet.

LG
LINUS19
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Mi 27.12.17 01:11 
du verwechselst jerade index.php mit index.html
die html Datei erzeugt den Button. Wenn du darauf klickst wird index.php ausgeführt und darin die python-Datei und somit die LED zum leuchten gebracht.
Kommt bei dir jetzt also bei index.html oder index.php ne leere Seite / was Passiert bei dir bei beiden?
Du kannst bzw solltest sie auch mal einzeln aufrufen

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Mi 27.12.17 12:52 
Auf der index.html Seite und bei der index.php Seite sehe ich den Button und in der Konsole kommen keinen Fehlermeldungen, ich denke es muss an irgendwelchen Ausfùhrungrechten liegen.
LINUS19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 156
Erhaltene Danke: 1

Windows 10, 7
Java(Eclipse)
BeitragVerfasst: Mi 27.12.17 13:07 
Hab hier mal ein Teil des Errorlogs von Apache2:
ausblenden volle Höhe Quelltext
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:
[Mon Dec 25 10:41:06.541686 2017] [mpm_event:notice] [pid 2286:tid 1995468800] AH00489: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Dec 25 10:41:06.542153 2017] [core:notice] [pid 2286:tid 1995468800] AH00094: Command line: '/usr/sbin/apache2'
[Mon Dec 25 11:03:04.775075 2017] [mpm_event:notice] [pid 2286:tid 1995468800] AH00491: caught SIGTERM, shutting down
[Mon Dec 25 11:03:06.028514 2017] [mpm_prefork:notice] [pid 5623] AH00163: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Dec 25 11:03:06.028881 2017] [core:notice] [pid 5623] AH00094: Command line: '/usr/sbin/apache2'
[Mon Dec 25 11:03:08.177307 2017] [mpm_prefork:notice] [pid 5623] AH00169: caught SIGTERM, shutting down
[Mon Dec 25 11:03:09.614692 2017] [mpm_prefork:notice] [pid 5727] AH00163: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Dec 25 11:03:09.614873 2017] [core:notice] [pid 5727] AH00094: Command line: '/usr/sbin/apache2'
[Mon Dec 25 11:10:09.283728 2017] [:error] [pid 5730] [client 192.168.178.45:56384] script '/var/www/html/phpinfo.php' not found or unable to stat
[Mon Dec 25 12:06:54.532902 2017] [:error] [pid 5731] [client 192.168.178.45:56614] PHP Notice:  Undefined index: licht_an in /var/www/html/tag07_neu/index.php on line 9
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
[Mon Dec 25 12:37:29.759482 2017] [:error] [pid 6275] [client 192.168.178.38:39976] PHP Notice:  Undefined index: licht_an in /var/www/html/tag07_neu/index.php on line 9
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
python: can't open file '/var/www/html/tag07/07led.py': [Errno 2] No such file or directory
[Mon Dec 25 13:19:50.760989 2017] [mpm_prefork:notice] [pid 5727] AH00169: caught SIGTERM, shutting down
[Mon Dec 25 13:19:59.896079 2017] [mpm_prefork:notice] [pid 661] AH00163: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Dec 25 13:19:59.901204 2017] [core:notice] [pid 661] AH00094: Command line: '/usr/sbin/apache2'
[Mon Dec 25 20:03:17.593107 2017] [mpm_prefork:notice] [pid 661] AH00169: caught SIGTERM, shutting down
[Mon Dec 25 20:03:26.238726 2017] [mpm_prefork:notice] [pid 667] AH00163: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Dec 25 20:03:26.249576 2017] [core:notice] [pid 667] AH00094: Command line: '/usr/sbin/apache2'
[Mon Dec 25 20:15:00.550137 2017] [mpm_prefork:notice] [pid 667] AH00169: caught SIGTERM, shutting down
[Mon Dec 25 20:15:10.356352 2017] [mpm_prefork:notice] [pid 623] AH00163: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Dec 25 20:15:10.362988 2017] [core:notice] [pid 623] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 26 11:48:00.101947 2017] [mpm_prefork:notice] [pid 623] AH00169: caught SIGTERM, shutting down
[Tue Dec 26 11:48:07.704464 2017] [mpm_prefork:notice] [pid 664] AH00163: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Tue Dec 26 11:48:07.743319 2017] [core:notice] [pid 664] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 26 17:58:07.590056 2017] [:error] [pid 667] [client 192.168.178.38:37151] PHP Notice:  Undefined index: licht_an in /var/www/html/tag07_neu/index.php on line 9


Was mich nur wundert ist das er die Python Datei nicht findet, obwohl sie in dem Ordner tag07_neu drin ist.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 27.12.17 13:37 
Er sucht ja aber offensichtlich nicht in tag07_neu sondern in tag07 ...

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".

Für diesen Beitrag haben gedankt: LINUS19