簡體   English   中英

Apache2.4.20編譯錯誤:/ usr / bin / ld:找不到-lssl和-lcrypto

[英]Apache2.4.20 Compilation error: /usr/bin/ld: cannot find -lssl and -lcrypto

我目前正在忙於關於網絡服務器之間差異的單身漢項目。 為了檢測這些,我試圖建立一個Docker容器的集合。 目前,我已經有一些從源代碼編譯並運行的Nginx服務器。 然而,與Apache相同似乎是一個挑戰。 除了Nginx dockerfiles之外,我根本沒有編譯經驗。

我正在嘗試使用OpenSSL 1.0.2從源代碼編譯apache 2.4.20。

我嘗試了以下dockerfile(它適用於具有不同OpenSSL版本的Apache 2.4.39):

FROM debian

# Install build requirements (or grab from docker cache)
RUN apt-get update && apt-get install wget git subversion make \
libpcre3-dev \
libpcre++-dev \
libxml2-dev \
libexpat1-dev \
python \
autoconf \
libtool-bin \
libpcre3-dev -y && \
git clone https://github.com/apache/httpd.git


ENV OPENSSL_VERSION=1.0.2   
ARG OPENSSL_VERSION

ENV APACHE_VERSION=2.4.20
ARG APACHE_VERSION

# Install APACHE

# RUN wget https://archive.apache.org/dist/httpd/httpd-${APACHE_VERSION}.tar.gz && \
# tar zxf httpd-${APACHE_VERSION}.tar.gz && \

RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz && tar xzvf openssl-${OPENSSL_VERSION}.tar.gz && \
cd openssl-${OPENSSL_VERSION} && ./Configure linux-x86_64 shared -fpic && make && make install && \
rm -rf /*.tar.gz


RUN cd /httpd && git checkout tags/${APACHE_VERSION} && svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr && ./buildconf
RUN cd httpd && ./configure \
--enable-dav \
--enable-so \
--enable-maintainer-mode \
--prefix=/usr/local/apache2 \
--with-mpm=worker \
--enable-layout=Apache \
--enable-mods-shared=most \
--with-included-apr \
--enable-static-support \
--enable-ssl=static \
--with-ssl=../openssl-${OPENSSL_VERSION} && \  
make && \
make install

# Remove build dependencies
RUN apt-get remove wget git subversion make \
libpcre3-dev \
libpcre++-dev \
libxml2-dev \
python \
autoconf \
libtool-bin \
libpcre3-dev -y && \
apt-get autoremove -y && \
rm -rf /httpd

# Copy SSL certs and configs
RUN mkdir -p /usr/local/apache2/ssl && rm -f /usr/local/apache2/conf/httpd.conf && rm -f /usr/local/apache2/conf/extra/httpd-ssl.conf
COPY ./shared/apache/apache.crt /usr/local/apache2/ssl/apache.crt
COPY ./shared/apache/apache.key /usr/local/apache2/ssl/apache.key
COPY ./shared/apache/conf/httpd.conf /usr/local/apache2/conf/httpd.conf
COPY ./shared/apache/conf/extra/httpd-ssl.conf /usr/local/apache2/conf/extra/httpd-ssl.conf

EXPOSE 80
EXPOSE 443

CMD ["./usr/local/apache2/bin/httpd","-DFOREGROUND"]

我在httpd目錄中執行make命令時出現以下錯誤。

/httpd/srclib/apr/libtool --silent --mode=link gcc  -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -Wpointer-arith -Wdeclaration-after-statement -Werror=declaration-after-statement -Wformat -Wformat-security -Werror=format-security   -L/openssl-1.0.2/lib -lssl -lcrypto -lcrypt -lrt -lpthread -ldl -lexpat  \
         -o ab -static ab.lo       /httpd/srclib/apr/libapr-2.la -lcrypt -lrt -lcrypt -lpthread -ldl -lexpat -lm
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
Makefile:73: recipe for target 'ab' failed
make[2]: Leaving directory '/httpd/support'
make[2]: *** [ab] Error 1

我嘗試了較舊和較新的openssl版本,但這並不重要。 較新的版本在編譯過程的早期拋出了棄用的警告(編譯器拋出的錯誤)。 較舊的版本給了我同樣的錯誤,或者當他們真的老了,關於缺少方法。

我也嘗試按照另一個線程中的建議安裝libssl-dev ,但也沒有用。

任何幫助或提示都非常感謝!

您正在構建自定義OpenSSL版本,但是您沒有添加將openssl(很可能是/ usr / local)安裝到LDFLAGS的路徑。 我認為--with-ssl=/usr/local應該解決你的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM