ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Apache源码安装

2022-07-15 11:32:35  阅读:184  来源: 互联网

标签:httpd apr root 源码 usr mr Apache include 安装


目录

1. 下载编译工具和源码包及其依赖包

下载编译工具
[root@mr ~]# dnf -y install gcc gcc-c++ make wget
CentOS Stream 8 - AppStream                                     18 kB/s |  24 MB     22:02    
CentOS Stream 8 - BaseOS                                        22 kB/s |  23 MB     17:49    
CentOS Stream 8 - Extras                                       330  B/s |  18 kB     00:55    
Last metadata expiration check: 0:00:01 ago on Fri 15 Jul 2022 09:33:24 AM CST.
Dependencies resolved.
......
Installed:
  binutils-2.30-117.el8.x86_64                   cpp-8.5.0-13.el8.x86_64                       
  gcc-8.5.0-13.el8.x86_64                        gcc-c++-8.5.0-13.el8.x86_64                   
  glibc-devel-2.28-206.el8.x86_64                glibc-gconv-extra-2.28-206.el8.x86_64         
  glibc-headers-2.28-206.el8.x86_64              isl-0.16.1-6.el8.x86_64                       
  kernel-headers-4.18.0-394.el8.x86_64           libmpc-1.1.0-9.1.el8.x86_64                   
  libpkgconf-1.4.2-1.el8.x86_64                  libstdc++-devel-8.5.0-13.el8.x86_64           
  libxcrypt-devel-4.1.1-6.el8.x86_64             make-1:4.2.1-11.el8.x86_64                    
  pkgconf-1.4.2-1.el8.x86_64                     pkgconf-m4-1.4.2-1.el8.noarch                 
  pkgconf-pkg-config-1.4.2-1.el8.x86_64          wget-1.19.5-10.el8.x86_64                     

Complete!
[root@mr ~]# 
下载源码包httpd-2.4.54.tar.gz,apr-1.7.0.tar.gz,apr-util-1.6.1.tar.gz
[root@mr ~]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
--2022-07-15 10:09:16--  https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 43.224.184.227, 45.253.17.212, 43.224.184.229, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|43.224.184.227|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9743277 (9.3M) [application/octet-stream]
Saving to: ‘httpd-2.4.54.tar.gz’

httpd-2.4.54.tar.gz     100%[==============================>]   9.29M   173KB/s    in 74s     

2022-07-15 10:10:35 (128 KB/s) - ‘httpd-2.4.54.tar.gz’ saved [9743277/9743277]

[root@mr ~]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
--2022-07-15 10:10:46--  https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 43.224.184.228, 45.253.17.217, 45.253.17.215, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|43.224.184.228|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093896 (1.0M) [application/octet-stream]
Saving to: ‘apr-1.7.0.tar.gz’

apr-1.7.0.tar.gz        100%[==============================>]   1.04M   167KB/s    in 6.4s    

2022-07-15 10:10:52 (167 KB/s) - ‘apr-1.7.0.tar.gz’ saved [1093896/1093896]

[root@mr ~]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
--2022-07-15 10:11:01--  https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 45.253.17.212, 45.253.17.214, 43.224.184.225, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|45.253.17.212|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K) [application/octet-stream]
Saving to: ‘apr-util-1.6.1.tar.gz’

apr-util-1.6.1.tar.gz   100%[==============================>] 541.31K   175KB/s    in 3.1s    

2022-07-15 10:11:04 (175 KB/s) - ‘apr-util-1.6.1.tar.gz’ saved [554301/554301]
[root@mr ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
[root@mr ~]# 

2. 安装apr

[root@mr ~]# tar -xf apr-1.7.0.tar.gz (解压apr-1.7.0.tar.gz)
[root@mr ~]# cd apr-1.7.0
[root@mr apr-1.7.0]#  ./configure --prefix=/usr/local/src/apr    (生成Makefile
一般常用的有 --prefix=PREFIX 这个选项的意思是定义软件包安装到哪里
建议,源码包都是安装在/opt/目录下或者/usr/local/src目录下面)
......
config.status: creating Makefile
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
[root@mr apr-1.7.0]# make(编译生成Makefile)
......
ude/arch/unix -I./include/arch/unix -I/root/apr-1.7.0/include/arch/unix -I/root/apr-1.7.0/include -I/root/apr-1.7.0/include/private -I/root/apr-1.7.0/include/private  exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$/\1/' >> apr.exp
gcc -E -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I./include -I/root/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/root/apr-1.7.0/include/arch/unix -I/root/apr-1.7.0/include -I/root/apr-1.7.0/include/private -I/root/apr-1.7.0/include/private  export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> apr.exp
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/src/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/src/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
make[1]: Leaving directory '/root/apr-1.7.0'
[root@mr apr-1.7.0]# make install(进行安装)
make[1]: Entering directory '/root/apr-1.7.0'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/root/apr-1.7.0'
/root/apr-1.7.0/build/mkdir.sh /usr/local/src/apr/lib /usr/local/src/apr/bin /usr/local/src/apr/build-1 \
	     /usr/local/src/apr/lib/pkgconfig /usr/local/src/apr/include/apr-1
......
    /usr/bin/install -c -m 644 /root/apr-1.7.0/build/${f} /usr/local/src/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/src/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/src/apr/bin/apr-1-config
[root@mr apr-1.7.0]# cd /usr/local/src/apr/(进入apr路径查看)
[root@mr apr]# ls
bin  build-1  include  lib
[root@mr apr]# cd /etc/ld.so.conf.d/
[root@mr ld.so.conf.d]# echo /usr/local/src/apr/lib/ >apr.conf
[root@mr ld.so.conf.d]# cd - (切换到前一个工作目录)
/usr/local/src/apr
[root@mr apr]# ldconfig (使命令生效)
[root@mr apr]# ln -s /usr/local/s
sbin/  share/ src/   
[root@mr apr]# ln -s /usr/local/src/apr/include/ /usr/include/apr(将头文件软链接到/usr/include目录下)
[root@mr apr]# ll /usr/include/apr
lrwxrwxrwx. 1 root root 27 Jul 15 10:27 /usr/include/apr -> /usr/local/src/apr/include/
[root@mr apr]# 

3. 安装apr-util

[root@mr ~]# dnf -y install expat-devel libxml2-devel pcre-devel(安装依赖包)
......
Upgraded:
  expat-2.2.5-9.el8.x86_64              libxml2-2.9.7-14.el8.x86_64   pcre-8.42-6.el8.x86_64  
  python3-libxml2-2.9.7-14.el8.x86_64  

Installed:
  cmake-filesystem-3.20.2-4.el8.x86_64              expat-devel-2.2.5-9.el8.x86_64             
  libxml2-devel-2.9.7-14.el8.x86_64                 pcre-cpp-8.42-6.el8.x86_64                 
  pcre-devel-8.42-6.el8.x86_64                      pcre-utf16-8.42-6.el8.x86_64               
  pcre-utf32-8.42-6.el8.x86_64                      xz-devel-5.2.4-3.el8.x86_64                
  zlib-devel-1.2.11-17.el8.x86_64                  

Complete!
[root@mr ~]# tar -xf apr-util-1.6.1.tar.gz (解压apr-util-1.6.1.tar.gz)
[root@mr ~]# cd apr-util-1.6.1
[root@mr apr-util-1.6.1]# ./configure --prefix=/usr/local/src/apr-util --with-apr=/usr/local/src/apr(生成Makefile文件,需要伴随着上一个指定的依赖)
......
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[root@mr apr-util-1.6.1]# make(编译生成的Makefile文件)
......
include/private/apr_crypto_internal.h /root/apr-util-1.6.1/include/private/apr_dbd_internal.h /root/apr-util-1.6.1/include/private/apr_dbd_odbc_v2.h /root/apr-util-1.6.1/include/private/apr_dbm_private.h /root/apr-util-1.6.1/include/private/apu_internal.h > export_vars.c
gcc -E -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/root/apr-util-1.6.1/include -I/root/apr-util-1.6.1/include/private  -I/usr/local/src/apr/include/apr-1    exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$/\1/' >> aprutil.exp
gcc -E -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/root/apr-util-1.6.1/include -I/root/apr-util-1.6.1/include/private  -I/usr/local/src/apr/include/apr-1    export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> aprutil.exp
sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
make[1]: Leaving directory '/root/apr-util-1.6.1'
[root@mr apr-util-1.6.1]# make install(进行安装)
......
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/src/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/src/apr-util/bin/apu-1-config
[root@mr apr-util-1.6.1]# cd /usr/local/src/apr-util/(切换到apr-util安装目录进行查看,默认情况下,系统搜索库文件的路径只有/lib,/usr/lib,我们需要进行修改在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中。此时库文件增添的搜索路径重启后有效,若要使用增添的路径立即生效则要使用ldconfig命令)
[root@mr apr-util]# ls
bin  include  lib
[root@mr apr-util]# cd /etc/ld.so.conf.d/ 
[root@mr ld.so.conf.d]# echo /usr/local/src/apr-util/ >apr-util.conf 
[root@mr ld.so.conf.d]# cd -
/usr/local/src/apr-util 
[root@mr apr-util]# ldconfig(使其生效)
[root@mr apr-util]# ln -s /usr/local/src/apr-util/include/ /usr/include/apr-util(将头文件软链接到/usr/include目录下)
[root@mr apr-util]# ll /usr/include/apr-util/
total 4
drwxr-xr-x. 2 root root 4096 Jul 15 10:39 apr-1
lrwxrwxrwx. 1 root root   32 Jul 15 10:45 include -> /usr/local/src/apr-util/include/
[root@mr apr-util]# 

4. 安装httpd

[root@mr ~]# tar -xf httpd-2.4.54.tar.gz (解压httpd-2.4.54.tar.gz)
[root@mr ~]# cd httpd-2.4.54
[root@mr httpd-2.4.54]# ./configure --prefix=/usr/local/src/httpd --with-apr=/usr/local/src/apr --with-apr-util=/usr/local/src/apr-util(生成makefile文件)
......
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.54
    Install prefix: /usr/local/src/httpd
    C compiler:     gcc
    CFLAGS:          -g -O2 -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E

[root@mr httpd-2.4.54]# make(编译生成makefile文件)
......
/root/httpd-2.4.54/modules/generators -I/root/httpd-2.4.54/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
/usr/local/src/apr/build-1/libtool --silent --mode=link gcc  -g -O2 -pthread           -o mod_rewrite.la -rpath /usr/local/src/httpd/modules -module -avoid-version  mod_rewrite.lo 
make[4]: Leaving directory '/root/httpd-2.4.54/modules/mappers'
make[3]: Leaving directory '/root/httpd-2.4.54/modules/mappers'
make[2]: Leaving directory '/root/httpd-2.4.54/modules'
make[2]: Entering directory '/root/httpd-2.4.54/support'
make[2]: Leaving directory '/root/httpd-2.4.54/support'

make[1]: Leaving directory '/root/httpd-2.4.54'
[root@mr httpd-2.4.54]# make install(进行安装)
......
mkdir /usr/local/src/httpd/include
Installing build system files
mkdir /usr/local/src/httpd/build
Installing man pages and online manual
mkdir /usr/local/src/httpd/man
mkdir /usr/local/src/httpd/man/man1
mkdir /usr/local/src/httpd/man/man8
mkdir /usr/local/src/httpd/manual
make[1]: Leaving directory '/root/httpd-2.4.54'
[root@mr httpd-2.4.54]# cd /usr/local/src/httpd/(切换到httpd的安装目录进行查看,默认情况下,系统搜索库文件的路径只有/lib,/usr/lib)
[root@mr httpd]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@mr httpd]# ldconfig (使其生效)
[root@mr httpd]# ln -s /usr/local/src/httpd/include/ /usr/include/httpd(将头文件软链接到/usr/include目录下)
[root@mr httpd]# ll /usr/include/httpd
lrwxrwxrwx. 1 root root 29 Jul 15 10:56 /usr/include/httpd -> /usr/local/src/httpd/include/
[root@mr httpd]# 
配置httpd的全局环境变量,并生成效果
[root@mr httpd]# echo "export PATH=$PATH:/usr/local/src/httpd/bin" > /etc/profile.d/httpd.sh
[root@mr httpd]# source /etc/profile.d/httpd.sh 
[root@mr httpd]# which httpd
/usr/local/src/httpd/bin/httpd
[root@mr httpd]# vi /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/src/httpd/man(添加这一行)
[root@mr ~]#httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::9d7b:f18b:2f8c:1ed1%ens33. Set the 'ServerName' directive globally to suppress this message
[root@mr ~]# dnf provides netstat
Last metadata expiration check: 1:22:13 ago on Fri 15 Jul 2022 09:54:51 AM CST.
net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools
Repo        : baseos
Matched from:
Filename    : /usr/bin/netstat

[root@mr ~]# dnf -y install net-tools
Last metadata expiration check: 1:23:44 ago on Fri 15 Jul 2022 09:54:51 AM CST.
Dependencies resolved.
===============================================================================================
 Package            Architecture    Version                              Repository       Size
===============================================================================================
Installing:
 net-tools          x86_64          2.0-0.52.20160912git.el8             baseos          322 k

Transaction Summary
===============================================================================================
Install  1 Package
......
Running transaction
  Preparing        :                                                                       1/1 
  Installing       : net-tools-2.0-0.52.20160912git.el8.x86_64                             1/1 
  Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64                             1/1 
  Verifying        : net-tools-2.0-0.52.20160912git.el8.x86_64                             1/1 
Installed products updated.

Installed:
  net-tools-2.0-0.52.20160912git.el8.x86_64                                                    

Complete!
[root@mr ~]# netstat -antp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      41628/httpd         
[root@mr ~]#  ss -antl
State     Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process    
LISTEN    0          128                  0.0.0.0:22                0.0.0.0:*                  
LISTEN    0          128                     [::]:22                   [::]:*                  
LISTEN    0          128                        *:80                      *:*                  
[root@mr ~]# systemctl stop firewalld.service(关闭防火墙)

5. 服务80端口

标签:httpd,apr,root,源码,usr,mr,Apache,include,安装
来源: https://www.cnblogs.com/marymary/p/16480695.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有