开发者

Calling Mono from PHP

it's a bit complicated. :-) I have a website written in PHP that needs to call an external program written in .NET, running under Mono. It calls the program with:

/path/mono /path/executable arguments...

as per usual (I also tried to put this into a bash script and call the script itself from PHP).

As far as I can tell, everything is set up as required. Mono itself running all right, executable (or script) with executable rights, owners are all right. The correct setup can also be ascertained from the fact that if I issue the command line above (or call the script mentioned) from a command line on the server (Debian Lenny), everything works perfectly, my executable is executed without error.

But, if PHP calls the same (using exec(), system() or any other variant), I immediately get an exit code of 6 from Mono and my executable is not run at all (in order to test it, I use a "Hello World" executable that does nothing but emits a single output line and returns 0). Compiled without any additional dependency, just a real "Hello Word". It's absolutely sure that this program doesn't return the exit code 6, it must come from Mono but I couldn't find 开发者_开发知识库it documented anywhere.

I can call anything else from PHP, so it's not safe mode or any similar restriction that would keep me from executing external programs from PHP.

Thanks for any idea...


Try to execute mono from the command line but with the user running the webserver (www-data or apache).

ej.

#su apache
$/path/to/mono /path/to/program.exe

The common problems that I have using exec is a different environment variables (look if is bash or sh what apache is using), permissions to the user/group of apache, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜