0

I have a PHP script that calls a C# program with mono:

exec("/opt/mono/bin/mono myprog.exe param1 param2");

When I execute my script on terminal as root:

# php myscript.php 

myprog.exe is executed normally. But when I try to execute this script as apache user (on browser user click in submit button with form action = myscript.php) I received error 11 on PHP exec function. What am I doing wrong?

I already made

chmod 777 /opt/mono/bin/mono

and in the program that I am running

chmod 755 myprog.exe

myprog.exe is in apache folder /var/www/html.

I'm using CentOS on Azure and mono version 3.2.8 (installed as described in https://gist.github.com/andreazevedo/9479518)

This is happening only in server. At my local machine its working.

Harison Silva
  • 98
  • 1
  • 8
  • 1
    maybe you should look into [mod mono](http://www.mono-project.com/docs/web/mod_mono/) instead and cut out PHP as the middle man? – Franz Gleichmann Nov 15 '16 at 18:57
  • thanks, I will see it. But I still wondering why this is happening. – Harison Silva Nov 15 '16 at 19:05
  • 2
    Apache runs things as a different user and group than when you run the application from the CLI. It maybe that the mono application is accessing a file that the apache user does not have permissions for. – Tim Nov 15 '16 at 19:09
  • Following [Vic Seedoubleyew](http://stackoverflow.com/questions/36577020/php-failed-to-open-stream-no-such-file-or-directory/36577021#36577021) answer I disable SELinux and now it works! – Harison Silva Nov 16 '16 at 03:18

1 Answers1

0

I received error 11 on PHP exec

Error 11 is segmentation fault. PHP is reading and executing myprog.exe properly. But mono/myprog.exe ITSELF is breaking.

If you can execute it fine as your user it maybe that apache or php is not allowing enough memory to be used for mono/myprog.exe? Check your configs.

Dellowar
  • 3,160
  • 1
  • 18
  • 37