![安装 apache 时出错](https://linux22.com/image/876317/%E5%AE%89%E8%A3%85%20apache%20%E6%97%B6%E5%87%BA%E9%94%99.png)
处理时出现错误make install
。我的代码如下:
git clone https://github.com/apache/httpd.git
cd httpd
svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr && cd srclib/apr && ./buildconf && ./build libtool && make && make install
./buildconf && ./configure --prefix=/usr/local && make && make install
echo "ServerName localhost" >> /usr/local/conf/httpd.conf
错误如下:
...
Building shared: mod_mime.la
make[4]: Entering directory '/httpd/modules/http'
/usr/local/apr/build-2/libtool --silent --mode=compile gcc -std=gnu99 -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/httpd/os/unix -I/httpd/include -I/usr/local/apr/include/apr-2 -I/httpd/modules/aaa -I/httpd/modules/cache -I/httpd/modules/core -I/httpd/modules/database -I/httpd/modules/filters -I/httpd/modules/ldap -I/httpd/modules/loggers -I/httpd/modules/lua -I/httpd/modules/proxy -I/httpd/modules/session -I/httpd/modules/ssl -I/httpd/modules/test -I/httpd/server -I/httpd/modules/arch/unix -I/httpd/modules/dav/main -I/httpd/modules/generators -I/httpd/modules/mappers -prefer-pic -c mod_mime.c && touch mod_mime.slo
/usr/local/apr/build-2/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread -o mod_mime.la -rpath /usr/local/modules -module -avoid-version mod_mime.lo
make[4]: Leaving directory '/httpd/modules/http'
make[3]: Leaving directory '/httpd/modules/http'
make[3]: Entering directory '/httpd/modules/http2'
Building shared: mod_http2.la
make[4]: Entering directory '/httpd/modules/http2'
/usr/local/apr/build-2/libtool --silent --mode=compile gcc -std=gnu99 -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/httpd/os/unix -I/httpd/include -I/usr/local/apr/include/apr-2 -I/httpd/modules/aaa -I/httpd/modules/cache -I/httpd/modules/core -I/httpd/modules/database -I/httpd/modules/filters -I/httpd/modules/ldap -I/httpd/modules/loggers -I/httpd/modules/lua -I/httpd/modules/proxy -I/httpd/modules/session -I/httpd/modules/ssl -I/httpd/modules/test -I/httpd/server -I/httpd/modules/arch/unix -I/httpd/modules/dav/main -I/httpd/modules/generators -I/httpd/modules/mappers -prefer-pic -c mod_h2.c && touch mod_h2.slo
mod_h2.c:25:29: fatal error: nghttp2/nghttp2.h: No such file or directory
#include <nghttp2/nghttp2.h>
^
compilation terminated.
/httpd/build/rules.mk:213: recipe for target 'mod_h2.slo' failed
make[4]: *** [mod_h2.slo] Error 1
make[3]: *** [shared-build-recursive] Error 1
make[4]: Leaving directory '/httpd/modules/http2'
/httpd/build/rules.mk:117: recipe for target 'shared-build-recursive' failed
make[3]: Leaving directory '/httpd/modules/http2'
/httpd/build/rules.mk:117: recipe for target 'shared-build-recursive' failed
make[2]: Leaving directory '/httpd/modules'
make[2]: *** [shared-build-recursive] Error 1
/httpd/build/rules.mk:117: recipe for target 'shared-build-recursive' failed
make[1]: Leaving directory '/httpd'
make[1]: *** [shared-build-recursive] Error 1
/httpd/build/rules.mk:75: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
请提供解决方案
答案1
那个部分
git clone https://github.com/apache/httpd.git cd httpd svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr && cd srclib/apr && ./buildconf && ./build libtool && make && make install ./buildconf && ./configure --prefix=/usr/local && make && make install echo "ServerName localhost" >> /usr/local/conf/httpd.conf
非常令人困惑。但由于错误消息:
通过以下方式安装缺少的库
sudo apt-get install libnghttp2-dev
sudo apt-get install libxml2-dev
你必须使用
sudo make install
代替
make install
在命令队列的末尾。否则,您可能会立即收到下一个错误。
答案2
您收到错误“/httpd/build/rules.mk:75:目标‘all-recursive’的配方失败”的原因是因为您缺少 Apache2 的开发库。
执行以下操作:sudo apt install apache2-dev -y ; sudo make ; sudo make install