设为首页 收藏本站
查看: 750|回复: 0

[经验分享] centos7编译安装httpd2.4.25

[复制链接]

尚未签到

发表于 2019-2-15 11:14:04 | 显示全部楼层 |阅读模式
源码的好处是比较灵活,想放哪里定制路径就放哪里
  前提准备:Centos7系统、下载httpd2.4源代码、安装编译前的软件环境;连接教室物理网络。
  1、下载httpd2.4.25源码
[root@Magedu ~]# yum -y install lftp
[root@Magedu ~]# lftpget ftp://172.18.0.1/pub/Sources/sources/httpd/httpd-2.4.25.tar.bz2
将下载好的http2.4.25进行解压缩,
[root@centos7 data]# ll
total 6268
-rw-------  1 root root     1421 Jan 30 13:05 anaconda-ks.cfg
-rwxr-xr-x  1 root root      360 Jan 26 14:24 hallo.sh
drwxr-xr-x 11  501 games    4096 Dec 17  2016 httpd-2.4.25
-rw-r--r--  1 root root  6398218 Oct 15 08:31 httpd-2.4.25.tar.bz2
-rw-r--r--  1 root root      984 Jan 24 20:34 magedu.pubkey
[root@centos7 data]# du -sh httpd-2.4.25
43M httpd-2.4.25
[root@centos7 data]# cd httpd-2.4.25/
[root@centos7 httpd-2.4.25]# ls
ABOUT_APACHE     CMakeLists.txt  INSTALL         NWGNUmakefile
acinclude.m4     config.layout   InstallBin.dsp  os
Apache-apr2.dsw  configure       LAYOUT          README
Apache.dsw       configure.in    libhttpd.dep    README.cmake
apache_probes.d  docs            libhttpd.dsp    README.platforms
ap.d             emacs-style     libhttpd.mak    ROADMAP
build            httpd.dep       LICENSE         server
BuildAll.dsp     httpd.dsp       Makefile.in     srclib
BuildBin.dsp     httpd.mak       Makefile.win    support
buildconf        httpd.spec      modules         test
CHANGES          include         NOTICE          VERSIONING
[root@centos7 httpd-2.4.25]# tree
│       └── wintty.mak
├── test
│   ├── check_chunked
│   ├── cls.c
│   ├── Makefile.in
│   ├── make_sni.sh
│   ├── README
│   ├── tcpdumpscii.txt
│   ├── test_find.c
│   ├── test_limits.c
│   ├── test_parser.c
│   ├── test_select.c
│   ├── test-writev.c
│   └── time-sem.c
└── VERSIONING
  95 directories, 2776 files
可以看到有非常多“ . c  ”文件,
[root@centos7 httpd-2.4.25]# find -name "*.c" |wc -l
284                      共284个
对于此类复杂脚本如何编译安装,我们接着看:
  2、安装编译前的环境即安装Development tools包组及依赖
[root@Magedu ~]# yum -y groupinstall “Development Tools”
[root@centos7 httpd-2.4.25]# make
make: *** No targets specified and no makefile found.  Stop.
[root@centos7 httpd-2.4.25]# which make
/usr/bin/make
[root@centos7 httpd-2.4.25]# rpm -qf /usr/bin/make
make-3.82-23.el7.x86_64
[root@centos7 httpd-2.4.25]# file /usr/bin/make
/usr/bin/make: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=77eee6e2b89ced609bef92cd9ef75bb7e056d83b, stripped
make本身是一个二进制文件,要借助于mskefile文本文件。
我们要在Makefile文件中放安装路径,那些文件启用哪些文件不启用。利用 make 项目管理器就能实现自动安装和编译安装。
  3、预编译config配置
[root@centos7 httpd-2.4.25]# ./configure --prefix=/apps/httpd/ --sysconfdir=/etc/httpd/ --enable-ssl
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found.  Please read the documentation.
[root@centos7 httpd-2.4.25]# yum search apr
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
============================= N/S matched: apr =============================
apr-devel.i686 : APR library development kit
apr-devel.x86_64 : APR library development kit
apr-util-devel.i686 : APR utility library development kit
apr-util-devel.x86_64 : APR utility library development kit
apr-util-ldap.x86_64 : APR utility library LDAP support
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
apr-util-nss.x86_64 : APR utility library NSS crytpo support
apr-util-odbc.x86_64 : APR utility library ODBC DBD driver
apr-util-openssl.x86_64 : APR utility library OpenSSL crytpo support
apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver
apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver
libapreq2-devel.x86_64 : Development files for libapreq2
libchromaprint-devel.x86_64 : Headers for developing programs that will use
: chromaprint
pcp-pmda-haproxy.x86_64 : Performance Co-Pilot (PCP) metrics for HAProxy
php-whitehat101-apr1-md5.noarch : Apache's APR1-MD5 algorithm in pure PHP
apr.i686 : Apache Portable Runtime library
apr.x86_64 : Apache Portable Runtime library
apr-util.i686 : Apache Portable Runtime Utility library
apr-util.x86_64 : Apache Portable Runtime Utility library
golang-github-armon-go-proxyproto-devel.noarch : Golang package to handle
: HAProxy Proxy Protocol
haproxy.x86_64 : TCP/HTTP proxy and load balancer for high availability
: environments
libapreq2.x86_64 : Apache HTTP request library
libchromaprint.x86_64 : Library implementing the AcoustID fingerprinting
libfap.x86_64 : An APRS parser written in C
perl-libapreq2.x86_64 : Perl interface to the Apache HTTP request library
snapraid.x86_64 : Disk array backup for many large rarely-changed files
Name and summary matches only, use "search all" for everything.
[root@centos7 httpd-2.4.25]# yum install apr-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package apr-devel.x86_64 0:1.4.8-3.el7_4.1 will be installed
--> Finished Dependency Resolution
  Dependencies Resolved
============================================================================
Package         Arch         Version               Repository         Size

  Installing:
apr-devel       x86_64       1.4.8-3.el7_4.1       development       188 k
Transaction Summary
  Install  1 Package
  Total download size: 188 k
Installed size: 771 k
Is this ok [y/d/N]: y
Downloading packages:
apr-devel-1.4.8-3.el7_4.1.x86_64.rpm                   | 188 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-devel-1.4.8-3.el7_4.1.x86_64                         1/1
Verifying  : apr-devel-1.4.8-3.el7_4.1.x86_64                         1/1
  Installed:
apr-devel.x86_64 0:1.4.8-3.el7_4.1
  Complete!
此处报错提示“ checking for APR... no ”,我们要安装的是“ yum install apr-devel ”。
  我们再次检查,报错提示:
[root@centos7 httpd-2.4.25]# ./configure --prefix=/apps/httpd/ --sysconfdir=/etc/httpd/ --enable-ssl
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-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 "  -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.
[root@centos7 httpd-2.4.25]# yum search apr
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
============================= N/S matched: apr =============================
apr-devel.i686 : APR library development kit
apr-devel.x86_64 : APR library development kit
apr-util-devel.i686 : APR utility library development kit
apr-util-devel.x86_64 : APR utility library development kit
apr-util-ldap.x86_64 : APR utility library LDAP support
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
apr-util-nss.x86_64 : APR utility library NSS crytpo support
apr-util-odbc.x86_64 : APR utility library ODBC DBD driver
apr-util-openssl.x86_64 : APR utility library OpenSSL crytpo support
apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver
apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver
libapreq2-devel.x86_64 : Development files for libapreq2
libchromaprint-devel.x86_64 : Headers for developing programs that will use
: chromaprint
pcp-pmda-haproxy.x86_64 : Performance Co-Pilot (PCP) metrics for HAProxy
php-whitehat101-apr1-md5.noarch : Apache's APR1-MD5 algorithm in pure PHP
apr.i686 : Apache Portable Runtime library
apr.x86_64 : Apache Portable Runtime library
apr-util.i686 : Apache Portable Runtime Utility library
apr-util.x86_64 : Apache Portable Runtime Utility library
golang-github-armon-go-proxyproto-devel.noarch : Golang package to handle
: HAProxy Proxy Protocol
haproxy.x86_64 : TCP/HTTP proxy and load balancer for high availability
: environments
libapreq2.x86_64 : Apache HTTP request library
libchromaprint.x86_64 : Library implementing the AcoustID fingerprinting
libfap.x86_64 : An APRS parser written in C
perl-libapreq2.x86_64 : Perl interface to the Apache HTTP request library
snapraid.x86_64 : Disk array backup for many large rarely-changed files
  Name and summary matches only, use "search all" for everything.
[root@centos7 httpd-2.4.25]# yum install apr-util-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package apr-util-devel.x86_64 0:1.5.2-6.el7 will be installed
--> Processing Dependency: openldap-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: expat-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Running transaction check
---> Package expat-devel.x86_64 0:2.1.0-10.el7_3 will be installed
---> Package libdb-devel.x86_64 0:5.3.21-24.el7 will be installed
---> Package openldap-devel.x86_64 0:2.4.44-20.el7 will be installed
--> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.44-20.el7.x86_64
--> Running transaction check
---> Package cyrus-sasl-devel.x86_64 0:2.1.26-23.el7 will be installed
--> Finished Dependency Resolution
  Dependencies Resolved
============================================================================
Package              Arch       Version              Repository       Size

  Installing:
apr-util-devel       x86_64     1.5.2-6.el7          development      76 k
Installing for dependencies:
cyrus-sasl-devel     x86_64     2.1.26-23.el7        development     310 k
expat-devel          x86_64     2.1.0-10.el7_3       development      57 k
libdb-devel          x86_64     5.3.21-24.el7        development      38 k
openldap-devel       x86_64     2.4.44-20.el7        development     804 k
Transaction Summary
  Install  1 Package (+4 Dependent packages)
Total download size: 1.3 M
Installed size: 5.2 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): apr-util-devel-1.5.2-6.el7.x86_64.rpm           |  76 kB   00:00     
(2/5): cyrus-sasl-devel-2.1.26-23.el7.x86_64.rpm       | 310 kB   00:00     
(3/5): expat-devel-2.1.0-10.el7_3.x86_64.rpm           |  57 kB   00:00     
(4/5): libdb-devel-5.3.21-24.el7.x86_64.rpm            |  38 kB   00:00     
(5/5): openldap-devel-2.4.44-20.el7.x86_64.rpm         | 804 kB   00:00     

  Total                                          1.2 MB/s | 1.3 MB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libdb-devel-5.3.21-24.el7.x86_64                         1/5
Installing : expat-devel-2.1.0-10.el7_3.x86_64                        2/5
Installing : cyrus-sasl-devel-2.1.26-23.el7.x86_64                    3/5
Installing : openldap-devel-2.4.44-20.el7.x86_64                      4/5
Installing : apr-util-devel-1.5.2-6.el7.x86_64                        5/5
Verifying  : openldap-devel-2.4.44-20.el7.x86_64                      1/5
Verifying  : apr-util-devel-1.5.2-6.el7.x86_64                        2/5
Verifying  : cyrus-sasl-devel-2.1.26-23.el7.x86_64                    3/5
Verifying  : expat-devel-2.1.0-10.el7_3.x86_64                        4/5
Verifying  : libdb-devel-5.3.21-24.el7.x86_64                         5/5
  Installed:
apr-util-devel.x86_64 0:1.5.2-6.el7
  Dependency Installed:
cyrus-sasl-devel.x86_64 0:2.1.26-23.el7                                   
expat-devel.x86_64 0:2.1.0-10.el7_3                                       
libdb-devel.x86_64 0:5.3.21-24.el7                                       
openldap-devel.x86_64 0:2.4.44-20.el7                                    
Complete!
我们按上面的思路安装即可。第一次安装无经验,下一次安装就知道缺什么,就可直接安装了。
  4、编译:[root@Magedu httpd-2.4.25]# make -j 4
注意:使用-j 4表示编译时,使用4个cpu同时工作
  5、安装:[root@Magedu httpd-2.4.25]# make install
6、添加全局环境变量即将执行命令和帮助文档的路径写入PATH
[root@Magedu httpd-2.4.25]# vim /etc/profile.d/env.sh
添加:
export PATH=/app/apache24/BIN:$PATH
使其立即生效:
[root@Magedu httpd-2.4.25]# source
/etc/profile.d/env.sh
配置帮助文档路径:
[root@Magedu httpd-2.4.25]# vim /etc/man_db.conf
添加:
MANDATORY_MANPATH
/app/apache24/man
  7、关闭防火墙:
[root@Magedu ~]# apachectl start
[root@Magedu ~]# iptables -F
完成!




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-672325-1-1.html 上篇帖子: CentOS 7 文件/目录的权限及归属 下篇帖子: CentOS 7 install Zabbix3.4
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表