MTK Android Built-in Nginx server method

Source: Internet
Author: User
Tags nginx server

Because of the needs of the project, you need a built-in Nginx on an Android 6572 method.
First, use ARM-LINUX-GCC to compile nginx.
Let's install nginx manually to see if it works, and then integrate it in the middle of the code if it works.
1, now Android above build Gnulib environment
Push the relevant library to the Android/system/lib/first
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
Then put the relevant configuration file into the/system/etc/
Group
Host.conf
Hosts
LocalTime
Nsswitch.conf
passwd
resolv.conf
and/system/etc/nginx/conf the Nginx server.
ADB remount
ADB shell
CD SYSTEM/ETC
mkdir Nginx
CD Nginx
mkdir conf
Files include
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
Finally, put the compiled nginx into/system/bin/and modify the executable properties
ADB push nginx/system/bin/
ADB shell chmod 777/system/bin/nginx
After push, enter ADB shell test run
ADB shell
Nginx-c/system/etc/nginx/conf/nginx.conf
Tips
[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)
We need to build android.nginx/logs under/data/data/.
ADB shell
cd/data/data/
mkdir Android.nginx
CD Android.nginx
mkdir logs
Executes again and can be executed correctly.
Open the browser on your phone and enter 127.0.0.1 to execute correctly.
Of course, specific implementation results require the installation project requires custom nginx.conf files.

The following nginx built into the source code of MTK 6572
The first step, built-in Gnulib library,
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
Put it in./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/lib
The second step is to put the Gnulib configuration file
Group
Host.conf
Hosts
LocalTime
Nsswitch.conf
passwd
resolv.conf
Put it under the./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/etc.

The third step, the Nginx server configuration related files
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
Put it under the./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/etc/nginx/conf.

Fourth step, in./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/etc/nginx/ Place the files I need to place under the Wwwroot folder

Fifth step, put the nginx under the./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/bin

Sixth step, create a script file
#!/system/bin/sh
Nginx-c/system/etc/nginx/conf/nginx.conf
Name Startnginx
Placed below the./alps/vendor/mediatek/project_name/artifacts/out/target/product/project_name/system/bin

Seventh step, modify Alps/mediatek/config/mt6572/init.rc, add in on Post-fs-data
Mkdir/data/data/android.nginx
mkdir/data/data/android.nginx/logs/
Eighth step, modify the alps/mediatek/config/mt6572/init.rc, add nginx start
Service Init-setup/system/bin/startnginx
Class Main
User root
Group Root
OneShot
On property:sys.boot_completed=1
Start Init-setup

Then new again code. Ok.


MTK Android Built-in Nginx server method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.