OpenWRT SDK重新编译nginx

最近想在自己的路由器上安装Nginx,然后将自己经常用到的软件放在上面随时下载。

言归正传,以安装OpenWRT-18.06.6为例,nginx默认安装不支持SSL,不够安全,且自带的autoindex太难看,因此想重新编译nginx,把需要的都加上。

编译环境一般不建议用root用户,最好新建一个普通用户。

操作系统:Ubuntu 16.04.6 x64

Ubuntu 编译环境依赖:

sudo apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc zip

重新编译需要先下载OpenWRT 的SDK,先通过官网下载SDK,我自己的路由器是 NewWIFI 3,CPU是 mtk7621,因此需要找到以下SDK,如果自己的路由器是其他型号CPU,请根据自身具体情况选择性下载。

https://downloads.openwrt.org/releases/19.07.1/targets/ramips/mt7621/openwrt-sdk-19.07.1-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz

操作过程

cd ~
wget https://downloads.openwrt.org/releases/19.07.1/targets/ramips/mt7621/openwrt-sdk-19.07.1-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz

tar xJf openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64.tar.xz
cd openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64


#openWRT原有的源速度很慢,改为github的相对好些,改不改都不影响编译。
vi feeds.conf.default
# 删除原有内容,将以下四行贴到文件中保存退出。
src-git base https://github.com/openwrt/openwrt.git;openwrt-18.06
src-git packages https://github.com/openwrt/packages.git;openwrt-18.06
src-git luci https://github.com/openwrt/luci.git;openwrt-18.06
src-git routing https://github.com/openwrt-routing/packages.git;openwrt-18.06

#然后执行:
./scripts/feeds update -a   
./scripts/feeds install -a

 操作结果示例:

#./scripts/feeds update -a   执行结果:

xuws@OpenWRT-CompileENV:~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64$ ./scripts/feeds update -a
Updating feed 'base' from 'https://github.com/openwrt/openwrt.git;openwrt-18.06' ...
Cloning into './feeds/base'...
remote: Enumerating objects: 7933, done.
remote: Counting objects: 100% (7933/7933), done.
remote: Compressing objects: 100% (6681/6681), done.
Receiving objects: 100% (7933/7933), 10.19 MiB | 14.00 KiB/s, done.
remote: Total 7933 (delta 1277), reused 3992 (delta 682), pack-reused 0
Resolving deltas: 100% (1277/1277), done.
Checking connectivity... done.
Create index file './feeds/base.index' 
Collecting package info: done
Collecting target info: done
Updating feed 'packages' from 'https://github.com/openwrt/packages.git;openwrt-18.06' ...
Cloning into './feeds/packages'...
remote: Enumerating objects: 4345, done.
remote: Counting objects: 100% (4345/4345), done.
remote: Compressing objects: 100% (3720/3720), done.
Receiving objects: 100% (4345/4345), 2.58 MiB | 26.00 KiB/s, done.
remote: Total 4345 (delta 174), reused 2964 (delta 79), pack-reused 0
Resolving deltas: 100% (174/174), done.
Checking connectivity... done.
Create index file './feeds/packages.index' 
Collecting package info: done
Collecting target info: done
Updating feed 'luci' from 'https://github.com/openwrt/luci.git;openwrt-18.06' ...
Cloning into './feeds/luci'...
remote: Enumerating objects: 3956, done.
remote: Counting objects: 100% (3956/3956), done.
remote: Compressing objects: 100% (2322/2322), done.
Receiving objects: 100% (3956/3956), 3.75 MiB | 48.00 KiB/s, done.
remote: Total 3956 (delta 782), reused 2638 (delta 320), pack-reused 0
Resolving deltas: 100% (782/782), done.
Checking connectivity... done.
Create index file './feeds/luci.index' 
Collecting package info: done
Collecting target info: done
Updating feed 'routing' from 'https://github.com/openwrt-routing/packages.git;openwrt-18.06' ...
Cloning into './feeds/routing'...
remote: Enumerating objects: 422, done.
remote: Counting objects: 100% (422/422), done.
remote: Compressing objects: 100% (341/341), done.
remote: Total 422 (delta 33), reused 281 (delta 18), pack-reused 0
Receiving objects: 100% (422/422), 306.15 KiB | 103.00 KiB/s, done.
Resolving deltas: 100% (33/33), done.
Checking connectivity... done.
Create index file './feeds/routing.index' 
Collecting package info: done
Collecting target info: done


#如果在更新过程中有某一块代码无法更新,或想重新更新某一块代码,可以执行
./scripts/feeds/update packages
#执行结果:
xuws@OpenWRT-CompileENV:~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64$ ./scripts/feeds update packages
Updating feed 'packages' from 'https://github.com/openwrt/packages.git;openwrt-18.06' ...
Cloning into './feeds/packages'...
remote: Enumerating objects: 4345, done.
remote: Counting objects: 100% (4345/4345), done.
remote: Compressing objects: 100% (3720/3720), done.
Receiving objects: 100% (4345/4345), 2.58 MiB | 26.00 KiB/s, done.
remote: Total 4345 (delta 174), reused 2964 (delta 79), pack-reused 0
Resolving deltas: 100% (174/174), done.
Checking connectivity... done.
Create index file './feeds/packages.index' 
Collecting package info: done
Collecting target info: done
xuws@OpenWRT-CompileENV:~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64$

 操作结果示例:

#./scripts/feeds install -a 执行结果:
# 部分告警不影响,可以忽略

xuws@OpenWRT-CompileENV:~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64$ ./scripts/feeds install -a
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'r8169-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'e100-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'bnx2-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'ar3k-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'mwifiex-sdio-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'kmod-phy-bcm-ns-usb2', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'edgeport-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'kmod-phy-bcm-ns-usb3', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'prism54-firmware', which does not exist
WARNING: Makefile 'package/linux/Makefile' has a dependency on 'rtl8192su-firmware', which does not exist
Installing all packages from feed base.
Installing package '6in4' from base
Installing package 'uclient' from base
Installing package 'ustream-ssl' from base
Installing package 'libubox' from base
Installing package 'lua' from base
……这里省略1w字
Installing package 'luci-app-ocserv' from luci
Installing package 'luci-app-olsr' from luci
Installing package 'luci-lib-luaneightbl' from luci
Installing package 'luci-app-olsr-services' from luci
Installing package 'luci-app-olsr-viz' from luci
Installing package 'luci-app-openvpn' from luci
Installing package 'luci-app-p910nd' from luci
Installing package 'luci-app-pagekitec' from luci
Installing package 'luci-app-polipo' from luci
Installing package 'luci-app-privoxy' from luci
Installing package 'luci-app-qos' from luci
Installing package 'luci-app-radicale' from luci
Installing package 'luci-app-rp-pppoe-server' from luci
Installing package 'luci-app-samba' from luci
Installing package 'luci-app-shadowsocks-libev' from luci
Installing package 'luci-app-shairplay' from luci
Installing package 'luci-app-siitwizard' from luci
Installing package 'luci-app-simple-adblock' from luci
Installing package 'luci-app-splash' from luci
Installing package 'luci-app-squid' from luci
Installing package 'luci-app-statistics' from luci
Installing package 'luci-app-tinyproxy' from luci
Installing package 'luci-app-transmission' from luci
Installing package 'luci-app-travelmate' from luci
Installing package 'luci-app-udpxy' from luci
Installing package 'luci-app-uhttpd' from luci
Installing package 'luci-app-unbound' from luci
Installing package 'luci-app-upnp' from luci
Installing package 'luci-app-vnstat' from luci
Installing package 'luci-app-vpnbypass' from luci
Installing package 'luci-app-watchcat' from luci
Installing package 'luci-app-wifischedule' from luci
Installing package 'luci-app-wireguard' from luci
Installing package 'luci-proto-wireguard' from luci
Installing package 'luci-app-wol' from luci
Installing package 'luci-lib-httpclient' from luci
Installing package 'luci-lib-px5g' from luci
Installing package 'luci-lib-rpcc' from luci
Installing package 'luci-light' from luci
Installing package 'luci-mod-admin-mini' from luci
Installing package 'luci-theme-openwrt' from luci
Installing package 'luci-mod-failsafe' from luci
Installing package 'luci-mod-freifunk-community' from luci
Installing package 'luci-mod-rpc' from luci
Installing package 'luci-proto-3g' from luci
Installing package 'luci-proto-ipip' from luci
Installing package 'luci-proto-ncm' from luci
Installing package 'luci-proto-openconnect' from luci
Installing package 'luci-proto-qmi' from luci
Installing package 'luci-proto-relay' from luci
Installing package 'luci-proto-vpnc' from luci
Installing package 'luci-ssl' from luci
Installing package 'luci-ssl-openssl' from luci
Installing package 'luci-theme-freifunk-generic' from luci
Installing package 'luci-theme-material' from luci
Installing all packages from feed routing.
Installing package 'alfred' from routing
Installing package 'babel-pinger' from routing
Installing package 'babeld' from routing
Installing package 'batctl' from routing
Installing package 'batman-adv' from routing
Installing package 'batmand' from routing
Installing package 'bird' from routing
Installing package 'bird4-openwrt' from routing
Installing package 'bird6-openwrt' from routing
Installing package 'cjdns' from routing
Installing package 'hnetd' from routing
Installing package 'ohybridproxy' from routing

成功执行上述命令后,可以准备编译nginx

#先准备nginx的代码
cd ~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64
make package/nginx/prepare V=99

#执行结果,部分告警不影响。

xuws@OpenWRT-CompileENV:~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64$ make package/nginx/prepare V=99
Collecting package info: done
## 省略部分告警……
tmp/.config-package.in:73997:warning: ignoring type redefinition of 'PACKAGE_jshn' from 'boolean' to 'tristate'
tmp/.config-package.in:74331:warning: ignoring type redefinition of 'PACKAGE_libjson-script' from 'boolean' to 'tristate'
tmp/.config-package.in:79224:warning: ignoring type redefinition of 'PACKAGE_ubi-utils' from 'boolean' to 'tristate'
Config-build.in:8355:warning: defaults for choice values not supported
Config-build.in:8359:warning: defaults for choice values not supported
Config-build.in:8447:warning: defaults for choice values not supported
Config-build.in:8451:warning: defaults for choice values not supported
Config-build.in:8455:warning: defaults for choice values not supported
Config-build.in:8459:warning: defaults for choice values not supported
Config-build.in:8463:warning: defaults for choice values not supported
Config-build.in:8467:warning: defaults for choice values not supported
Config-build.in:8483:warning: defaults for choice values not supported
#
# configuration written to .config
#
make[1]: Entering directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64'
make[2]: Entering directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/feeds/packages/net/nginx'
touch /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/.prepared_23f1dba10ee2d6c66020d91c86240150_18f1e190c5d53547fed41a3eaa76e9e9_check
. /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/include/shell.sh; gzip -dc /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/dl/nginx-1.12.2.tar.gz | tar -C /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/.. -xf - 
[ ! -d ./src/ ] || cp -fpR ./src/. /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2

Applying ./patches/101-feature_test_fix.patch using plaintext: 
patching file auto/cc/name
patching file auto/cc/conf
patching file auto/os/linux
Hunk #2 succeeded at 110 (offset 17 lines).
Hunk #3 succeeded at 131 (offset 17 lines).
Hunk #4 succeeded at 149 (offset 17 lines).
patching file auto/unix
Hunk #1 succeeded at 788 (offset 53 lines).
Hunk #2 succeeded at 801 (offset 53 lines).
Hunk #3 succeeded at 816 (offset 53 lines).
Hunk #4 succeeded at 830 (offset 53 lines).

Applying ./patches/102-sizeof_test_fix.patch using plaintext: 
patching file auto/types/sizeof

Applying ./patches/103-sys_nerr.patch using plaintext: 
patching file src/os/unix/ngx_errno.c

Applying ./patches/200-config.patch using plaintext: 
patching file conf/nginx.conf

Applying ./patches/300-max-processes.patch using plaintext: 
patching file src/os/unix/ngx_process.h
touch /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/.prepared_23f1dba10ee2d6c66020d91c86240150_18f1e190c5d53547fed41a3eaa76e9e9
make[2]: Leaving directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/feeds/packages/net/nginx'
time: package/feeds/packages/nginx/prepare#0.16#0.07#0.60
make[1]: Leaving directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64'
xuws@OpenWRT-CompileENV:~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64$ 


 然后到准备好的代码目录中添加需要的模块,或者根据自己需要任意修改nginx代码

cd ~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64
cd build_dir/target-mipsel_24kc_musl/nginx-1.12.2
#添加ngx-fancyindex 模块,
git clone https://github.com/aperezdc/ngx-fancyindex.git

代码、模块准备完成后,需要修改Makefile文件,将需要增加的模块添加的编译命令中

cd openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/
cd package/feeds/packages/nginx
vi Makefile

#然后在Makefile文件中增加  --add-module=$(PKG_BUILD_DIR)/ngx-fancyindex
#效果如下:
define Build/Configure
        ( cd $(PKG_BUILD_DIR) ; \
                $(if $(CONFIG_NGINX_LUA),LUA_INC=$(STAGING_DIR)/usr/include LUA_LIB=$(STAGING_DIR)/usr/lib) \
                ./configure \
                        --crossbuild=Linux::$(ARCH) \
                        --prefix=/usr \
                        --conf-path=/etc/nginx/nginx.conf \
                        $(ADDITIONAL_MODULES) \
                        --error-log-path=/var/log/nginx/error.log \
                        --pid-path=/var/run/nginx.pid \
                        --lock-path=/var/lock/nginx.lock \
                        --http-log-path=/var/log/nginx/access.log \
                        --http-client-body-temp-path=/var/lib/nginx/body \
                        --http-proxy-temp-path=/var/lib/nginx/proxy \
                        --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
                        --with-cc="$(TARGET_CC)" \
                        --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
                        --with-ld-opt="$(TARGET_LDFLAGS)" \
                        --without-http_upstream_zone_module \
                        --add-module=$(PKG_BUILD_DIR)/ngx-fancyindex \   #增加的内容
        )
endef

然后开始进行编译:

cd ~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64
make package/nginx/configure V=99
# 执行结果如下:


#
# configuration written to .config
#
make[1]: Entering directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64'
make[2]: Entering directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/feeds/packages/net/nginx'
rm -f /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/.configured_*
rm -f /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/stamp/.nginx_installed
( cd /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2 ;  ./configure --crossbuild=Linux::mipsel --prefix=/usr --conf-path=/etc/nginx/nginx.conf  --with-ipv6 --without-http-cache --without-pcre --without-http_charset_module --without-http_gzip_module --without-http_ssi_module --without-http_userid_module --without-http_access_module --without-http_auth_basic_module --without-http_autoindex_module --without-http_geo_module --without-http_map_module --without-http_split_clients_module --without-http_referer_module --without-http_rewrite_module --without-http_proxy_module --without-http_fastcgi_module --without-http_uwsgi_module --without-http_scgi_module --without-http_memcached_module --without-http_limit_conn_module --without-http_limit_req_module --without-http_empty_gif_module --without-http_browser_module --without-http_upstream_hash_module --without-http_upstream_ip_hash_module --without-http_upstream_least_conn_module --without-http_upstream_keepalive_module --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-cc="mipsel-openwrt-linux-musl-gcc" --with-cc-opt="-I/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/usr/include -I/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/include -I/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/include -I/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include/fortify -I/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/include -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2:nginx-1.12.2 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fvisibility=hidden -ffunction-sections -fdata-sections -DNGX_LUA_NO_BY_LUA_BLOCK" --with-ld-opt="-L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/usr/lib -L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/lib -L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/lib -L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib -znow -zrelro -Wl,--gc-sections" --without-http_upstream_zone_module --add-module=/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/ngx-fancyindex )
building for Linux::mipsel
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 7.3.0 (OpenWrt GCC 7.3.0 r7957-d81a8a3e29) 
checking for gcc -pipe switch ... found
checking for --with-ld-opt="-L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/usr/lib -L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl/lib -L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/usr/lib -L/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/lib -znow -zrelro -Wl,--gc-sections" ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found but is not working
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux::mipsel specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... not found
checking for nogroup group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_RECVDSTADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... big endian
checking for size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for sys_nerr ... not found
checking for _sys_nerr ... not found
checking for maximum errno ... found but is not working
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
configuring additional modules
adding module in /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/ngx-fancyindex
 - The 'addition' filter is needed for fancyindex_{header,footer}, but it was disabled
 + ngx_http_fancyindex_module was configured
creating objs/Makefile

Configuration summary
  + PCRE library is disabled
  + OpenSSL library is not used
  + zlib library is not used

  nginx path prefix: "/usr"
  nginx binary file: "/usr/sbin/nginx"
  nginx modules path: "/usr/modules"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/var/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/lib/nginx/body"

./configure: warning: the "--with-ipv6" option is deprecated
touch /home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mipsel_24kc_musl/nginx-1.12.2/.configured_1211cc2ccfefb3c4f3690baa13976009
make[2]: Leaving directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/feeds/packages/net/nginx'
time: package/feeds/packages/nginx/configure#5.51#2.04#11.20
make[1]: Leaving directory '/home/xuws/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64'
make packege/nginx/compile V=99

编译过程请参考https://download.csdn.net/download/xwsnet/12135080

编译完成后即可将以下路径的nginx可执行文件拷贝到路由器中运行
 

cd ~/openwrt-sdk-18.06.6-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64/staging_dir/

cd target-mipsel_24kc_musl/root-ramips/usr/sbin

ls -lh

拷贝到路由器后,运行./nginx -V,检查编译后的nginx是否已经包含新增的模块

至此,新增加的模块已经成功编译进入nginx,如果有其他模块需要增加也同样道理,如果新增的模块需要依赖其他基础软件包,需要先安装依赖包,再进行编译。

依赖的编译包安装和nginx安装一样,例如需要安装 libxml2依赖包,安装过程如下:

make package/libxml2/clean V=99
make package/libxml2/prepare V=99
make package/libxml2/configure V=99
make package/libxml2/install V=99

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值