我发现我们可以通过访问此站点在 android 上运行 Phpcgi 。我在 android 中创建了一个 Web 服务器,它工作正常,我已经安装了 Php cgi,并想问我如何链接两者以便我可以运行 php 脚本以及 HTML 页面。任何帮助将不胜感激。
更新:
在我的请求处理器中,输出是这样发送的:
contentType = guessContentTypeFromName(filename);
Date now = new Date( );
out.write("Date: " + now + "\r\n");
out.write("Server: JHTTP/1.0\r\n");
out.write("Content-length: " + theData.length + "\r\n");
out.write("Content-type: " + contentType + "\r\n\r\n");
out.flush( );
猜测孔蒂....()
if (name.endsWith(".php")) {
String pathToPhpExecutable = Environment.getExternalStorageDirectory() + "/data" + "/php-cgi";
String phpFile ="" + "/php/myPhpFile.php";
Process process = null;
try {
process = new ProcessBuilder()
.command(pathToPhpExecutable, phpFile)
.redirectErrorStream(true)
.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
} finally {
process.destroy();
}