简体   繁体   English

php exec无法在Mamp上工作

[英]php exec not working on mamp

I'm trying to launch an executable myapp made with unity by using the following code in php, but I'm getting errors. 我正在尝试通过使用php中的以下代码来启动一个由统一性制成的可执行myapp,但出现错误。

<?php
echo "yo";
echo exec('whoami',$output,$retval);
echo $retval;
echo exec('myapp.app',$output,$retval);
echo $retval;
echo exec('/Applications/MAMP/htdocs/myapp.app/',$output,$retval);
echo $retval;
?>

The result is yodan127127. 结果是yodan127127。 127 I looked up in error codes means procedure not found. 127我在错误代码中查找表示未找到过程。

I have also commented out some lines in Applications/Mamp/Library/bin/envvars_ which was recommended in other posts. 我还注释了Applications / Mamp / Library / bin / envvars_中的某些行,这是其他帖子中推荐的。

I have put the myapp.app in several directories htdocs,bin,cgi-bin, but gives the same error. 我已经将myapp.app放在htdocs,bin,cgi-bin的几个目录中,但是给出了相同的错误。

#if test "x$DYLD_LIBRARY_PATH" != "x" ; then
#  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#else
#  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"
#fi
#export DYLD_LIBRARY_PATH
#

You have to point exec to the binary, and not the container for it. 您必须将exec指向二进制文件,而不是指向它的容器。

The .app is just a container directory that has an internal structure, the binary is somewhere in a path that should look like /Applications/MAMP/htdocs/myapp.app/Contents/MacOS/myapp . .app只是具有内部结构的容器目录,二进制文件位于路径中的某个位置,该路径应类似于/Applications/MAMP/htdocs/myapp.app/Contents/MacOS/myapp The precise location of the binary is in the /Applications/MAMP/htdocs/myapp.app/info.plist file. 二进制文件的确切位置在/Applications/MAMP/htdocs/myapp.app/info.plist文件中。 You can right click on the app and select show package contents to view the structure. 您可以右键单击该应用程序,然后选择显示包内容以查看结构。

But the easiest way to run the app is to open it with the open command: 但是运行应用程序的最简单方法是使用open命令打开它:

open '/Applications/MAMP/htdocs/myapp.app/'

It should be runnable from php as an argument to exec . 它应该可以从php作为exec的参数运行。

Excel推荐用于PHP,因此需要在服务器上安装,推荐像image magick等。然后使用exec()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM