標籤:android style io ar os 使用 sp 檔案 on
因為項目需要,需要在一台android 6572的方法上內建nginx.
首先,使用arm-linux-gcc編譯nginx。
我們先手動安裝nginx,看看是否可行,如果可行,然後再在代碼中間整合。
1, 現在android上面建立gnulib的環境
先把相關庫push到android的/system/lib/上
ld-linux.so.3
libc.so.6
libnsl.so.1
libnss_compat.so.2
libnss_dns.so.2
libnss_files.so.2
libnss_hesiod.so.2
libnss_nis.so.2
libnss_nisplus.so.2
libresolv.so.2
然後把相關設定檔放到/system/etc/
group
host.conf
hosts
localtime
nsswitch.conf
passwd
resolv.conf
還要把nginx伺服器的/system/etc/nginx/conf下面
adb remount
adb shell
cd system/etc
mkdir nginx
cd nginx
mkdir conf
檔案包括
fastcgi.conf
fastcgi.conf.default
fastcgi_params
fastcgi_params.default
install.sh
koi-utf
koi-win
mime.types
mime.types.default
nginx.conf
nginx.conf.default
scgi_params
scgi_params.default
uwsgi_params
uwsgi_params.default
win-utf
最後把編譯的nginx放到/system/bin/,並修改可執行屬性
adb push nginx /system/bin/
adb shell chmod 777 /system/bin/nginx
push之後,進入adb shell實驗運行
adb shell
nginx -c /system/etc/nginx/conf/nginx.conf
提示
[email protected]:/ # nginx -c /system/etc/nginx/conf/nginx.cong
nginx: [alert] could not open error log file: open() "/data/data/android.nginx/logs/error.log" failed (2: No such file or directory)
2013/01/01 08:55:24 [emerg] 3592#0: open() "/system/etc/nginx/conf/nginx.cong" failed (2: No such file or directory)
我們需要在/data/data/下面建立android.nginx/logs
adb shell
cd /data/data/
mkdir android.nginx
cd android.nginx
mkdir logs
再次執行,可以正確執行。
開啟手機端的瀏覽器,輸入127.0.0.1,可以正確執行。
當然具體執行結果需要安裝項目要求定製nginx.conf檔案了。
下面把nginx內建到mtk 6572的原始碼裡面
第一步,內建gnulib庫,把
ld-linux.so.3
libc.so.6
libnsl.so.1
libnss_compat.so.2
libnss_dns.so.2
libnss_files.so.2
libnss_hesiod.so.2
libnss_nis.so.2
libnss_nisplus.so.2
libresolv.so.2
放到./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/lib
第二步,把gnulib的設定檔
group
host.conf
hosts
localtime
nsswitch.conf
passwd
resolv.conf
放到./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/etc下面
第三步,把nginx伺服器的配置相關檔案
fastcgi.conf
fastcgi.conf.default
fastcgi_params
fastcgi_params.default
install.sh
koi-utf
koi-win
mime.types
mime.types.default
nginx.conf
nginx.conf.default
scgi_params
scgi_params.default
uwsgi_params
uwsgi_params.default
win-utf
放到./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/etc/nginx/conf下面
第四步,在./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/etc/nginx/wwwroot檔案夾下放置我所需要放置的檔案
第五步,把nginx放到./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/bin下面
第六步,建立一個指令檔
#!/system/bin/sh
nginx -c /system/etc/nginx/conf/nginx.conf
命名startNginx
放置到./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/bin下面
第七步,修改alps/mediatek/config/mt6572/init.rc,在on post-fs-data中添加
mkdir /data/data/android.nginx
mkdir /data/data/android.nginx/logs/
第八步,修改alps/mediatek/config/mt6572/init.rc,添加nginx的啟動
service init-setup /system/bin/startNginx
class main
user root
group root
oneshot
on property:sys.boot_completed=1
start init-setup
然後new一遍代碼。OK。
mtk android內建nginx伺服器的方法