building ngx_cache_purge module on CentOS Linux release 7.9.2009 (Core)

Kaushal Shriyan kaushalshriyan at gmail.com
Sun May 8 04:58:23 UTC 2022


Hi,

I am able to fix the issue below.

#nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] module
"/usr/lib64/nginx/modules/ngx_http_cache_purge_module.so" version 1020002
instead of 1020001 in
/usr/share/nginx/modules/ngx-http-cache-purge-module.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

Nginx Version :- nginx version: nginx/1.20.2
OS Version :- CentOS Linux release 7.9.2009 (Core)

cd /home/kaushal/nginx-1.20.2/
#./configure --with-compat --add-dynamic-module=../ngx-cache-purge
checking for OS
 + Linux 3.10.0-1160.62.1.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
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 specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... not found
checking for eventfd() ... 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 prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... 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() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... 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_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... 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 int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 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 ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 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 strerrordesc_np() ... not found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... 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 ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for ioctl(FIONREAD) ... 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 sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
configuring additional dynamic modules
adding module in ../ngx-cache-purge
 +  was configured
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

#make modules
make -f objs/Makefile modules
make[1]: Entering directory `/home/kaushal/nginx-1.20.2'
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter
-Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I
objs -I src/http -I src/http/modules \
-o objs/addon/ngx-cache-purge/ngx_cache_purge_module.o \
../ngx-cache-purge/ngx_cache_purge_module.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter
-Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I
objs -I src/http -I src/http/modules \
-o objs/ngx_http_cache_purge_module_modules.o \
objs/ngx_http_cache_purge_module_modules.c
cc -o objs/ngx_http_cache_purge_module.so \
objs/addon/ngx-cache-purge/ngx_cache_purge_module.o \
objs/ngx_http_cache_purge_module_modules.o \
-shared
make[1]: Leaving directory `/home/kaushal/nginx-1.20.2'

#cp ngx_http_cache_purge_module.so /etc/nginx/modules

cd /home/kaushal/ngx-cache-purge/
# ls -l
total 64
-rw-r--r-- 1 root root   728 May  8 02:48 config
-rw-r--r-- 1 root root 51501 May  8 02:48 ngx_cache_purge_module.c
-rw-r--r-- 1 root root  5090 May  8 02:48 README.md
# cat config
if [ "$HTTP_PROXY" = "YES" ]; then
    have=NGX_HTTP_PROXY . auto/have
fi

if [ "$HTTP_FASTCGI" = "YES" ]; then
    have=NGX_HTTP_FASTCGI . auto/have
fi

if [ "$HTTP_SCGI" = "YES" ]; then
    have=NGX_HTTP_SCGI . auto/have
fi

if [ "$HTTP_UWSGI" = "YES" ]; then
    have=NGX_HTTP_UWSGI . auto/have
fi

if test -n "$ngx_module_link"; then
    ngx_module_type=HTTP
    ngx_module_name=ngx_http_cache_purge_module
    ngx_module_srcs="$ngx_addon_dir/ngx_cache_purge_module.c"

    have=NGX_CACHE_PURGE_MODULE . auto/have

    . auto/module
else
    HTTP_MODULES="$HTTP_MODULES ngx_http_cache_purge_module"
    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_cache_purge_module.c"

    have=NGX_CACHE_PURGE_MODULE . auto/have
fi
#
# pwd
/etc/nginx/modules
# nginx -v
nginx version: nginx/1.20.2
# ls -l
total 88
-rwxr-xr-x 1 root root 88904 May  8 04:34 ngx_http_cache_purge_module.so
#

#nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] unknown directive "proxy_cache_purge" in
/etc/nginx/conf.d/default.conf:103
nginx: configuration file /etc/nginx/nginx.conf test failed

I have the nginx module /etc/nginx/modules/ngx_http_cache_purge_module.so
and I am attaching the file for your reference.

Please correct and guide me if I am missing something. Thanks in advance.

Best Regards,

Kaushal

On Sun, May 8, 2022 at 8:40 AM Kaushal Shriyan <kaushalshriyan at gmail.com>
wrote:

> Hi Sergey,
>
> I followed
> https://www.nginx.com/blog/compiling-dynamic-modules-nginx-plus/#load_module
> to generate the third party dynamic module
>
> Nginx Version :- nginx version: nginx/1.20.1
> OS Version :- CentOS Linux release 7.9.2009 (Core)
>
> cd /home/kaushal/ngx-cache-purge/
> # ls -l
> total 64
> -rw-r--r-- 1 root root   728 May  8 02:48 config
> -rw-r--r-- 1 root root 51501 May  8 02:48 ngx_cache_purge_module.c
> -rw-r--r-- 1 root root  5090 May  8 02:48 README.md
> # cat config
> if [ "$HTTP_PROXY" = "YES" ]; then
>     have=NGX_HTTP_PROXY . auto/have
> fi
>
> if [ "$HTTP_FASTCGI" = "YES" ]; then
>     have=NGX_HTTP_FASTCGI . auto/have
> fi
>
> if [ "$HTTP_SCGI" = "YES" ]; then
>     have=NGX_HTTP_SCGI . auto/have
> fi
>
> if [ "$HTTP_UWSGI" = "YES" ]; then
>     have=NGX_HTTP_UWSGI . auto/have
> fi
>
> if test -n "$ngx_module_link"; then
>     ngx_module_type=HTTP
>     ngx_module_name=ngx_http_cache_purge_module
>     ngx_module_srcs="$ngx_addon_dir/ngx_cache_purge_module.c"
>
>     have=NGX_CACHE_PURGE_MODULE . auto/have
>
>     . auto/module
> else
>     HTTP_MODULES="$HTTP_MODULES ngx_http_cache_purge_module"
>     NGX_ADDON_SRCS="$NGX_ADDON_SRCS
> $ngx_addon_dir/ngx_cache_purge_module.c"
>
>     have=NGX_CACHE_PURGE_MODULE . auto/have
> fi
> #
>
> #wget http://nginx.org/download/nginx-1.20.2.tar.gz
> #tar zxvf nginx-1.20.2.tar.gz
> #cd /home/kaushal/nginx-1.20.2/
> #./configure --with-compat --add-dynamic-module=../ngx-cache-purge
>
> #cat /usr/share/nginx/modules/ngx-http-cache-purge-module.conf
> load_module "/usr/lib64/nginx/modules/ngx_http_cache_purge_module.so";
>
> #cat /etc/nginx/nginx.conf
> user nginx;
> worker_processes auto;
> error_log /var/log/nginx/error.log;
> pid /run/nginx.pid;
>
> # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
> include /usr/share/nginx/modules/*.conf;
>
> #nginx -t -c /etc/nginx/nginx.conf
> nginx: [emerg] module
> "/usr/lib64/nginx/modules/ngx_http_cache_purge_module.so" version 1020002
> instead of 1020001 in
> /usr/share/nginx/modules/ngx-http-cache-purge-module.conf:1
> nginx: configuration file /etc/nginx/nginx.conf test failed
>
> Please correct and guide me if I am missing something. Thanks in advance.
>
> Best Regards,
>
> Kaushal
>
> On Sat, May 7, 2022 at 7:32 PM Sergey A. Osokin <osa at freebsd.org.ru>
> wrote:
>
>> Hi Kaushal,
>>
>> On Sat, May 07, 2022 at 06:31:59PM +0530, Kaushal Shriyan wrote:
>> >
>> > #gcc -o ngx_cache_purge_module ngx_cache_purge_module.c
>> > ngx_cache_purge_module.c:30:19: fatal error: nginx.h: No such file or
>> > directory
>> >  #include <nginx.h>
>> >                    ^
>> > compilation terminated.
>>
>> I'd recommend to follow this [1] blog post to create a dynamic module
>> for nginx.
>>
>> References:
>> 1. https://www.nginx.com/blog/compiling-dynamic-modules-nginx-plus/
>>
>> --
>> Sergey A. Osokin
>> _______________________________________________
>> nginx mailing list -- nginx at nginx.org
>> To unsubscribe send an email to nginx-leave at nginx.org
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20220508/494c34a3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginxpurge.conf
Type: application/octet-stream
Size: 6159 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20220508/494c34a3/attachment.obj>


More information about the nginx mailing list