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.
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
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
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
change the file/folder ownership and check chmod ?
any panel installed?
Pipe stderr to stdout and echo the results of the command.
This should assist you in identifying the issue.
^
My control panel uses three different php.ini
Maybe do a
find /etc -iname php\.ini -exec grep --color -in 'disable_function' {} \;
turn on verbose error messages? http://www.php.net/manual/en/function.error-reporting.php
I checked both and I don't find an option which is different and affects exec
It tried it with root and www-data as owner, I also gave the php file 777 rights.
No
It always says: "mkdir: cannot create directory `test': Permission denied"
No matter who is the owner or if it has 777 rights.
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!
It may be an SELinux permissions issue, if you're running RHEL or a derivative.
What's the output of
sestatus
?You mean just sestatus in putty?
Yes
root@nyc:~# sestatus
-bash: sestatus: command not found
I use debian 6.0.7 btw. Maybe this command isn't available with debian.
Why not nginx on both?
Sure, I could install nginx on the other too. But altough I would like to know what I did wrong
I'm new with linux and I think it's important to get it work 
I'm not into PHP so I don't know if
exec()
uses the relative directory, but try creating the full path, eg. withexec("mkdir /var/www/test");
or whatever.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.
Since it's exec alone that's affected, did you check phpinfo() to see if exec is enabled?
Is
/var/www/
itself owned bywww-data
or with 777 permission?Since you are modifying the parent directory.
@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!