Sentora Support Forums
PHP exec() and shell_exec() functions cause hanging - Printable Version

+- Sentora Support Forums (https://senforums.mach-hosting.com)
+-- Forum: Sentora Forum Archives (https://senforums.mach-hosting.com/forumdisplay.php?fid=5)
+--- Forum: Sentora Public Support Forums v1.0.x (https://senforums.mach-hosting.com/forumdisplay.php?fid=32)
+---- Forum: General Support Forum v1.0.x (https://senforums.mach-hosting.com/forumdisplay.php?fid=36)
+---- Thread: PHP exec() and shell_exec() functions cause hanging (/showthread.php?tid=1864)



PHP exec() and shell_exec() functions cause hanging - steve_nf - 08-10-2015

Hi guys,

I'm having a problem with the PHP functions exec() and shell_exec(). Nothing in the php after the exec will execute. Even a simple 
PHP Code:
exec("echo 'hello'"); 

causes it.

Things that could be the problem, and what I've tried:
  • The apache user may not have sufficient permissions. Though as the root user I did run 
    sudo -H -u www-data bash -c 'echo "I am $USER, with uid $UID"'
which worked fine.
  • The exec functions may still be blocked somehow, even though I have already erased everything in the disable_functions entry in  /etc/php5/apache2/php.ini, and restarted apache2:
[Image: 2be9c41387.png]

I've also tried including 'sudo', like exec("sudo echo 'hello'"); , but it didn't make a difference.

The problem only occurs on my DigitalOcean server that's running Ubuntu 12.04 with Sentora. On my local copy of the website, which is ran on Windows 10, I don't have this problem.

Edit: I'm aware that it's not great to use exec() as it leaves the website vulnerable. The reason why I'm using it is because my website works like this: User uploads an image, and a program written in C++ (on the server) runs on the image, extracting information. The information is then stored in a database, and the image is deleted. So, I use exec() to get the C++ program to run on the image. Is there a smarter way to go about doing this?

Any help would be appreciated. Thank you for your time!


RE: PHP exec() and shell_exec() functions cause hanging - TGates - 08-11-2015

That is because they are disabled for security purposes. You could try disabling suhosin for that domain only.
Module Admin > Apache Config > Override a virtual host > [select domain] >uncheck Suhosin box > Save > wait ~5 mins for daemon to run and update the httpd-vhosts.conf and try again.


RE: PHP exec() and shell_exec() functions cause hanging - steve_nf - 08-11-2015

(08-11-2015, 04:15 AM)TGates Wrote: That is because they are disabled for security purposes. You could try disabling suhosin for that domain only.
Module Admin > Apache Config > Override a virtual host > [select domain] >uncheck Suhosin box > Save > wait ~5 mins for daemon to run and update the httpd-vhosts.conf and try again.

Thanks! This solved it.