Php 将lighttpd服务器移植到Android
我正在尝试将lighttpd移植到android,以便用户可以在android设备上执行php脚本 从broswser中点击localhost:port,但我的脚本工作不正常 下面是运行时java代码 }Php 将lighttpd服务器移植到Android,php,android,mysql,arm,lighttpd,Php,Android,Mysql,Arm,Lighttpd,我正在尝试将lighttpd移植到android,以便用户可以在android设备上执行php脚本 从broswser中点击localhost:port,但我的脚本工作不正常 下面是运行时java代码 } 方法RunTimePRovider().execute()将在用户单击按钮时被调用。最好的方法是转到一个开源项目并查看代码副本资产 然后在你的设备或模拟器上检查它。我也使用这个项目在android中使用php和lighthttpd。+1作为第一个回答,非常感谢你使用我的应用程序。我已经开发
方法RunTimePRovider().execute()将在用户单击按钮时被调用。最好的方法是转到一个开源项目并查看代码副本
资产
然后在你的设备或模拟器上检查它。我也使用这个项目在android中使用php
和lighthttpd
。
+1作为第一个回答,非常感谢你使用我的应用程序。我已经开发了这个应用程序,即droidpp
。这个问题以前有人问过。DroidPp的首次发布。DroidPp的开发者r先生,很高兴与您交谈,请与我在一起10分钟。请??我想问一下,我正在使用DroidPp,我正在运行一个脚本,将数据写入文本文件,脚本运行正常,但数据未写入我的文本文件我是否设置了任何权限或任何东西请帮助。你所做的工作对我来说就像宝石一样:)我喜欢DroidPp。请回复…@punk我已在github上提交了DroidPp的问题请阅读。。。谢谢你。。
public class RunTimeProvider {
boolean isLoaded = false;
ProcessBuilder mysqlBuilder = new ProcessBuilder(new String[] {
"/data/data/com.Punk.Qs/mysqld",
"--defaults-file=/data/data/com.Punk.Qs/my.ini",
"--user=root",
"--language=/data/data/com.Punk.Qs/share/mysql/english" });
ProcessBuilder phpBuilder = new ProcessBuilder(new String[] {
"/data/data/com.Punk.Qs/php-cgi-ext", "-c",
"data/data/com.Punk.Qs/php.ini" });
ProcessBuilder lighttpdBuilder = new ProcessBuilder(new String[] {
"/data/data/com.Punk.Qs/lighttpd", "-f",
"data/data/com.Punk.Qs/lighttpd.conf" });
public void execute() {
File fphp = new File("/data/data/com.Punk.Qs/php-cgi-ext");
File flighttp = new File("/data/data/com.Punk.Qs/lighttpd");
File fmysql = new File("/data/data/com.Punk.Qs/mysqld");
if (fphp.exists() && flighttp.exists() && fmysql.exists()) {
try {
Runtime.getRuntime().exec(
"chmod 777 /data/data/com.Punk.Qs/lighttpd");
lighttpdBuilder.start();
//NativeApp(
"/data/data/com.Punk.Qs/lighttpd -f data/data/com.Punk.Qs/lighttpd.conf",
"lighttpd");
Log.w("Lighttpd Started ", "Lighttpd successfully started");
} catch (IOException e) {
Log.w("Lighttpd Startup failed ", e);
new ErrorLogger("Lighttpd", e.toString());
}
try {
Runtime.getRuntime().exec(
"chmod 777 /data/data/com.Punk.Qs/mysqld");
mysqlBuilder.start();
//NativeApp(
"/data/data/com.Punk.Qs/mysqld --defaults-file=/data/data/com.Punk.Qs/my.ini --user=root --language=/data/data/com.Punk.Qs/share/mysql/english",
"mySQl");
Log.d("mySQL Started ", "mySQL successfully started");
} catch (IOException e) {
Log.w("mySQL Startup failed ", e);
new ErrorLogger("mySQl", e.toString());
}
try {
Runtime.getRuntime().exec(
"chmod 777 /data/data/com.Punk.Qs/php-cgi-ext");
phpBuilder.start();
//NativeApp(
"/data/data/com.Punk.Qs/php-cgi-ext -c data/data/com.Punk.Qs/php.ini",
"phpCgi");
Log.d("PHP Started ", "PHP successfully started");
} catch (IOException e) {
Log.w("PHP Startup failed ", e);
new ErrorLogger("phpCgi", e.toString());
}
} else {
Log.w("Error Runime Lib", "RunTime Libs is missing");
}
// return b;
}
public void NativeApp(String cmd, String tag) {
Process nativeApp = null;
Log.d("Executing :", cmd);
try {
nativeApp = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
Log.e("RunTime Error : ", e.toString());
new ErrorLogger("RunTime", e.toString());
}
BufferedReader reader = new BufferedReader(new InputStreamReader(
nativeApp.getInputStream()));
int read;
char[] buffer = new char[4096 * 8];
StringBuffer output = new StringBuffer();
try {
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
} catch (IOException e) {
Log.e("IO Error : ", e.toString());
new ErrorLogger("IO", e.toString());
}
// Waits for the command to finish.
try {
nativeApp.waitFor();
} catch (InterruptedException e) {
Log.e("InterruptedException : ", e.toString());
new ErrorLogger("IntExp", e.toString());
}
String nativeOutput = output.toString();
if (nativeOutput != null)
isLoaded = true;
Log.d("Output from : " + cmd, nativeOutput);
new ErrorLogger("RunLib", nativeOutput);
}