21-1.手动编译apache服务
1.下载 Tarball https://httpd.apache.org/download.cgi 2.上传到服务器,并解压到 /usr/local/src drwxr-xr-x 12 1000 1000 4096 5月 18 05:21 httpd-2.4.48 3.cat README INSTALL $ ./configure --prefix=PREFIX #指定安装路径 $ make $ make install $ PREFIX/bin/apachectl start 4../configure --prefix=/usr/local/apache2 [root@gaocun httpd-2.4.48]# ./configure --prefix=/usr/local/apache2 checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... no configure: error: APR not found. Please read the documentation. 5.解决 configure: error: APR not found. Please read the documentation. 1.下载 APR http://apr.apache.org/download.cgi 2.解压到 /usr/local/src 3../configure --prefix=/usr/local/apr 4.make 5.make install 6.再次执行 ./configure --prefix=/usr/local/apache2 [root@gaocun httpd-2.4.48]# ./configure --prefix=/usr/local/apache2 checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" setting CFLAGS to " -g -O2 -pthread" setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE" setting LDFLAGS to " " configure: configure: Configuring Apache Portable Runtime Utility library... configure: checking for APR-util... no configure: error: APR-util not found. Please read the documentation. 7.解决 configure: error: APR-util not found. Please read the documentation. 1.下载 APR-util http://apr.apache.org/download.cgi 2.解压到 /usr/local/src [root@gaocun src]# tar -zxvf apr-util-1.6.1.tar.gz gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now 原因:这个Tarball没有经过zip压缩,所以不用使用-z来解压 3../configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config 4.make 编译时报错: xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include <expat.h> ^ 编译中断。 make[1]: *** [xml/apr_xml.lo] 错误 1 原因:缺少<expat.h>包 解决:yum install expat-devel 5.make install 8.再次执行 ./configure --prefix=/usr/local/apache2 报错 configure: checking for APR-util... no configure: error: APR-util not found. Please read the documentation. 原因:手动指定 apr和apr-util的路径 ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre 报错: checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 原因:未找到pcre 1.下载 https://sourceforge.net/projects/pcre/ 2.解压到/usr/local/src 3.生成Makefile ./configure --prefix=/usr/local/pcre 报错:configure: error: Invalid C++ compiler or C++ compiler flags 原因:缺少gcc-c++ 库 解决: yum install -y gcc-c++ 4.make 5.make install 9.再次执行 ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre configure: summary of build options: Server Version: 2.4.48 Install prefix: /usr/local/apache2 C compiler: gcc -std=gnu99 CFLAGS: -g -O2 -pthread CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE LDFLAGS: LIBS: C preprocessor: gcc -E 10.make 报错: collect2: error: ld returned 1 exit status Makefile:48: recipe for target 'htpasswd' failed make[2]: *** [htpasswd] Error 1 make[2]: Leaving directory '/etc/httpd-2.4.27/support' /etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/etc/httpd-2.4.27/support' /etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 原因:https://www.linuxidc.com/Linux/2017-08/146567.html 11.make install 正确编译apache2 1.下载 httpd https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.48.tar.bz 2.下载依赖软件 APR https://apache.claz.org//apr/apr-1.7.0.tar.gz 3.下载依赖软件 APR-util https://apache.claz.org//apr/apr-util-1.6.1.tar.gz 4.下载依赖软件 pcre https://sourceforge.net/projects/pcre/files/latest/download 5.下载<expat.h> 编译APR-util需要 yum install expat-devel 7.将httpd-2.4.48.tar.bz 解压到/usr/local/src 8.将apr-1.7.0.tar.gz 解压到 httpd-2.4.48/srclib 下,命名为apr 9.将apr-util-1.6.1.tar.gz 解压到httpd-2.4.48/srclib 下,命名为apr-util 10.生成Makefile ./configure \ --prefix=/usr/local/apache2/ \ --with-pcre=/usr/local/pcre/ \ --with-included-apr 11.编译 make 12.安装 make install 13.启动 ./apachectl -f /usr/local/apache2/conf/httpd.conf -k start 报错:[Mon Aug 02 14:40:56.986318 2021] [core:notice] [pid 9066:tid 139880478857024] AH00094: Command line: '/usr/local/apache2//bin/httpd -f /usr/local/apache2/conf/httpd.conf' #https://blog.csdn.net/a13568hki/article/details/103428237 ./apachectl -f /usr/local/apache2/conf/httpd.conf -k stop 14.DocumentRoot "/usr/local/apache2//htdocs" 指令用于指定apache所提供页面服务的根目录
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界