Click here to Skip to main content
15,881,882 members

Apache2 - execute Python scripts as pi user problem

MateoGlowinski asked:

Open original thread
Hi,
i've problem with Apache2. It is not executing Python Scripts which includes "sudo" command. Those scripts are working fine while running from terminal (as a "pi" user).

Apache2 is running also "pi" user.
Response for ps aux | grep apache2 command:
root       409  0.0  0.4   7544  3824 ?        Ss   18:48   0:00 /usr/sbin/apache2 -k start
pi         410  0.0  0.3   7292  3036 ?        S    18:48   0:00 /usr/sbin/apache2 -k start
pi         411  0.0  0.4 231032  3872 ?        Sl   18:48   0:01 /usr/sbin/apache2 -k start
pi         412  0.0  0.4 231032  3872 ?        Sl   18:48   0:01 /usr/sbin/apache2 -k start
pi        1920  0.0  0.0   4372   556 pts/0    S+   20:17   0:00 grep --color=auto apache2


Python scripts are executable for every user:
-rwxrwxr-x  1 pi pi 1251 Aug 27 16:46 checkDisks.py
-rwxrwxr-x  1 pi pi 1650 Aug 30 05:52 checkDownload.py
-rwxrwxr-x  1 pi pi 1969 Aug 10 08:38 checkUSB.py
-rwxrwxr-x  1 pi pi  725 Aug 27 13:31 createUSB.py
drwxrwxr-x  3 pi pi 4096 Aug 30 05:14 current
-rwxrwxrwx  1 pi pi  522 Aug 27 20:25 deleteFiles.py
-rwxrwxrwx  1 pi pi  627 Aug  9 08:33 downloadLatest.py
drwxrwxr-x 34 pi pi 4096 Jul 31 15:42 dss-testautomation
drwxrwxr-x  7 pi pi 4096 May  3 14:46 dss-update-tester
-rw--w----  1 pi pi   28 Aug 27 19:53 nohup.out
-rwxrwxrwx  1 pi pi 1214 Aug 27 20:41 prepareSpace.py
drwxrwxr-x  3 pi pi 4096 May  3 11:02 testserver
-rw-rw-r--  1 pi pi  104 Aug  9 16:19 USB_lock
-rwxrwxrwx  1 pi pi 2187 Aug 20 14:29 usbOFF.py
-rwxrwxrwx  1 pi pi 3334 Aug 30 18:47 usbON.py
drwxrwxr-x  5 pi pi 4096 May  3 14:39 webpy_server


/var/log/apache2.error.log:
[Thu Aug 30 06:25:04.010021 2018] [mpm_event:notice] [pid 421:tid 1996357632] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 06:25:04.010214 2018] [core:notice] [pid 421:tid 1996357632] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 06:29:27.351568 2018] [mpm_event:notice] [pid 421:tid 1996357632] AH00491: caught SIGTERM, shutting down
[Thu Aug 30 06:29:30.780150 2018] [mpm_event:notice] [pid 425:tid 1996349440] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 06:29:30.782850 2018] [core:notice] [pid 425:tid 1996349440] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 07:11:05.987870 2018] [mpm_event:notice] [pid 425:tid 1996349440] AH00491: caught SIGTERM, shutting down
[Thu Aug 30 07:11:09.764342 2018] [mpm_event:notice] [pid 407:tid 1996001280] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 07:11:09.766669 2018] [core:notice] [pid 407:tid 1996001280] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 07:14:13.321922 2018] [mpm_event:notice] [pid 407:tid 1996001280] AH00491: caught SIGTERM, shutting down
[Thu Aug 30 07:14:16.745765 2018] [mpm_event:notice] [pid 412:tid 1996087296] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 07:14:16.747934 2018] [core:notice] [pid 412:tid 1996087296] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 07:20:01.962704 2018] [mpm_event:notice] [pid 412:tid 1996087296] AH00491: caught SIGTERM, shutting down
[Thu Aug 30 07:20:05.697280 2018] [mpm_event:notice] [pid 410:tid 1995591680] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 07:20:05.699445 2018] [core:notice] [pid 410:tid 1995591680] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 08:48:14.215742 2018] [mpm_event:notice] [pid 410:tid 1995591680] AH00491: caught SIGTERM, shutting down
[Thu Aug 30 08:48:17.779856 2018] [mpm_event:notice] [pid 407:tid 1996382208] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 08:48:17.782313 2018] [core:notice] [pid 407:tid 1996382208] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 09:56:42.876253 2018] [mpm_event:notice] [pid 411:tid 1995579392] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 09:56:42.879043 2018] [core:notice] [pid 411:tid 1995579392] AH00094: Command line: '/usr/sbin/apache2'
[Thu Aug 30 18:48:30.844159 2018] [mpm_event:notice] [pid 411:tid 1995579392] AH00491: caught SIGTERM, shutting down
[Thu Aug 30 18:48:34.752957 2018] [mpm_event:notice] [pid 409:tid 1996111872] AH00489: Apache/2.4.25 (Raspbian) configured -- resuming normal operations
[Thu Aug 30 18:48:34.755767 2018] [core:notice] [pid 409:tid 1996111872] AH00094: Command line: '/usr/sbin/apache2'


Any tips what can be wrong?

What I have tried:

I've tried to modify a /etc/sudoers file, but it didn't bring any result
Tags: Debian, Linux, Apache, Server, Raspberry-Pi

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900