M
M
Maxim Grakov2014-06-29 13:36:17
PHP
Maxim Grakov, 2014-06-29 13:36:17

Why is Apache2 doing exec() strangely?

Good evening gentlemen!
The point is this: for myself I write a Web-control panel for the laptop. It has Apache2, mod_python. I don’t look into the external network - I don’t bother with security. As a result, I got something like this state2.png:
Commands are executed by PHP by GET key, via system(). For example:

<?php

  if ($_GET["bright"] == "increace") { 
    exec('SBLM -up');

And now, in fact, the problem: some commands are not executed. system() does not return anything. For example, here it is:
if ($_GET["mocp"] == "prev") { 
   system('mocp -G');
    echo "Comlete";

in response - silence. At the same time right there through Geany - everything works. Tell me, in which direction to dig?
Thanks in advance
PS on board Ubuntu 14.04 with gnome.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neol, 2014-06-29
@GrakovNe

If apache is running from www-data, then most likely it does not have enough rights to access devices / sockets or something like that. Try to run as your user. To do this, in /etc/apache2/envvars you need to change the values

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

and restart apache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question