Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

exec(); works on nginx but not on apache2

trexostrexos Member

Hello,

I have to VPS running with debian 6.0.7 64 bit. On one runs apache2 with php5 and on the other nginx with php-fpm. I created an exec.php file which contains that:

<?php echo "successfully!"; exec("mkdir test"); ?>

On nginx it works perfectly right out of the box. But I can't make it run on apache2 webserver. I checked my php.ini (under /etc/php5/apache2/php.ini) and safe mode is off and exec isn't listed unter disable_functions.

Why doesn't exec work on apache2?:(

Thanks!

Comments

  • SplitIceSplitIce Member, Host Rep
    edited July 2013

    most likely they both use different php.ini's one most likely dissalows exec. You say you have checked, do a diff and compare.

    e.g
    /etc/php5/php5-fpm/php.ini
    and
    /etc/php5/apache2/php.ini

    Thanked by 1trexos
  • SpeedBusSpeedBus Member, Host Rep

    change the file/folder ownership and check chmod ?

    Thanked by 1trexos
  • LESLES Member
    edited July 2013

    any panel installed?

    Thanked by 1trexos
  • AdducAdduc Member
    edited July 2013

    Pipe stderr to stdout and echo the results of the command.

    echo exec("mkdir test 2>&1");
    

    This should assist you in identifying the issue.

    Thanked by 1trexos
  • DroidzoneDroidzone Member
    edited July 2013

    @Zen said:
    As everyone else said, probably using a different php configuration. That's the most common solution.

    ^
    My control panel uses three different php.ini

    Maybe do a find /etc -iname php\.ini -exec grep --color -in 'disable_function' {} \;

    Thanked by 1trexos
  • klikliklikli Member
    edited July 2013
    Thanked by 1trexos
  • trexostrexos Member

    @SplitIce said:
    most likely they both use different php.ini's one most likely dissalows exec. You say you have checked, do a diff and compare.

    e.g
    /etc/php5/php5-fpm/php.ini
    and
    /etc/php5/apache2/php.ini

    I checked both and I don't find an option which is different and affects exec :(

    @SpeedBus said:
    change the file/folder ownership and check chmod ?

    It tried it with root and www-data as owner, I also gave the php file 777 rights.

    @LES said:
    any panel installed?

    No :(

    @Adduc said:
    Pipe stderr to stdout and echo the results of the command.

    echo exec("mkdir test 2>&1");
    

    This should assist you in identifying the issue.

    It always says: "mkdir: cannot create directory `test': Permission denied"
    No matter who is the owner or if it has 777 rights.

    @joelgm said:
    Maybe do a find /etc -iname php\.ini -exec grep --color -in 'disable_function' {} \;

    As I don't use a panel, I think that won't help. But thanks!

    I did this with the comman from Adduc, didn't I?

    Thanks for your answers!

  • AdducAdduc Member
    edited July 2013

    It may be an SELinux permissions issue, if you're running RHEL or a derivative.

    What's the output of sestatus ?

    Thanked by 1trexos
  • trexostrexos Member

    You mean just sestatus in putty?

  • AdducAdduc Member

    Yes

    Thanked by 1trexos
  • trexostrexos Member

    root@nyc:~# sestatus
    -bash: sestatus: command not found

    I use debian 6.0.7 btw. Maybe this command isn't available with debian.

  • awsonawson Member

    @trexos said:
    I have to VPS running with debian 6.0.7 64 bit. On one runs apache2 with php5 and on the other nginx

    Why not nginx on both?

    Thanked by 1trexos
  • trexostrexos Member

    Sure, I could install nginx on the other too. But altough I would like to know what I did wrong :p I'm new with linux and I think it's important to get it work :)

  • awsonawson Member

    I'm not into PHP so I don't know if exec() uses the relative directory, but try creating the full path, eg. with exec("mkdir /var/www/test"); or whatever.

    Thanked by 1trexos
  • trexostrexos Member

    Doesn't change anything but thanks :(

  • CoreyCorey Member

    @trexos said:
    Doesn't change anything but thanks :(

    Think it has something to do with apache2 running under www-data and executing it as www-data and nginx runs as root.

    Thanked by 1trexos
  • DroidzoneDroidzone Member
    edited July 2013

    Since it's exec alone that's affected, did you check phpinfo() to see if exec is enabled?

    Thanked by 1trexos
  • msg7086msg7086 Member
    edited July 2013

    @trexos said:
    It always says: "mkdir: cannot create directory `test': Permission denied" No matter who is the owner or if it has 777 rights.

    Is /var/www/ itself owned by www-data or with 777 permission?

    Since you are modifying the parent directory.

    Thanked by 1trexos
  • trexostrexos Member

    @msg7086

    This was it! I don't know why it works under nginx, but under apache2 you have to set the owner of /var/www/ as www-data (makes sense, the script has to have the right to create a folder. So I have set 777 and chown www-data:www-data to all files in /var/www/, but not to the folder www itself.

    Thanks for all your answers!

Sign In or Register to comment.