使用 nginx 编译 nginx-auth-ldap 时出错

使用 nginx 编译 nginx-auth-ldap 时出错

我尝试在 Centos7 上使用 nginx 编译 ldap 模块。但是我遇到了大量的编译错误。

我在这里得到的前几个:

cc -c -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 /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 \
        -o objs/src/http/modules/ngx_http_stub_status_module.o \
        src/http/modules/ngx_http_stub_status_module.c
cc -c -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 /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/mail -I src/stream \
        -o objs/addon/ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.o \
        ./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:6:1: error: expected identifier or ‘(’ before ‘<’ token
 <!DOCTYPE html>
 ^
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:31:3: error: stray ‘\302’ in program
   <title>nginx-auth-ldap/ngx_http_auth_ldap_module.c at master · kvspb/nginx-auth-ldap · GitHub</title>
   ^
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:31:3: error: stray ‘\267’ in program
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:31:3: error: stray ‘\302’ in program
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:31:3: error: stray ‘\267’ in program
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:148:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
               </a>
               ^
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:174:267: error: expected identifier or ‘(’ before ‘<’ token
                     <a href="/features" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Features">Features <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a>
                                                                                                                                                                                                                                                                           ^
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:187:332: error: expected identifier or ‘(’ before ‘<’ token
                       <li class="edge-item-fix"><a href="/customer-stories" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Customer stories">Customer stories <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
                                                                                                                                                                                                                                                                                                                                            ^
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:188:308: error: expected identifier or ‘(’ before ‘<’ token
                       <li class="edge-item-fix"><a href="/security" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Security">Security <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
                                                                                                                                                                                                                                                                                                                    ^
./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:211:299: error: expected identifier or ‘(’ before ‘<’ token
                       <li class="edge-item-fix"><a href="/explore" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Explore">Explore GitHub <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>

我尝试使用 nginx 1.19 进行编译,并获取了最新版本github

在制作之前我做了:

下载并解压 nginx 1.19 的源代码 下载并解压(作为 nginx 源代码树中的子目录)nginx-ldap-auth 模块的源代码

yum install gcc zlib-devel openssl-devel make pcre-devel libxml2-devel libxslt-devel libgcrypt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_secure_link_module --add-module=./nginx-auth-ldap-master --with-http_auth_request_module --with-ipv6 --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 

我错过了什么?很久以前我做过同样的练习,还不错。只是时间太久了,记不清那一刻的来源了。

答案1

看起来您正在尝试“编译 HTML”。从错误中可以明显看出,只需仔细查看:

./ngx_http_auth_ldap_module/ngx_http_auth_ldap_module.c:6:1: error: expected identifier or ‘(’ before ‘<’ token
<!DOCTYPE HTML>
...

或者

<a href="/features" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Features">Features <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a>

发生这种情况可能是因为您使用了错误的链接下载 NGINX 或模块的源 tarball。

CentOS 代表社区企业操作系统。通过编译软件而不是使用可用的软件包,生产服务器存在明显的安全风险。

更好的替代方案是:

相关内容