【阿里云镜像】安装编译Apache环境

简介: 【阿里云镜像】安装编译Apache环境

一、参考链接🎨


阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区 (aliyun.com)


apache镜像-apache下载地址-apache安装教程-阿里巴巴开源镜像站 (aliyun.com)


Apache(Web服务器软件)_百度百科 (baidu.com)


编译安装_Apache中文文档 (apachehttpd.com)


二、Apache 简介


Apache(音译为阿帕奇)是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中。


下载地址:https://mirrors.aliyun.com/apache/


三、Apache编译安装(基于CentOS系统)


1、登录CentOS系统



2、安装依赖包


编译安装Apache HTTP Server,目前最新的版本为2.4.52,将apr,apr-util,pcre等相关依赖包编译安装好即可。


若上述安装包已全部安装完成,可以直接进行Apache安装。


🔴 apr安装


下载链接:https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz



# 测试YUM源是否能够正常
[root@centos apache]# yum clean all
[root@centos apache]# yum repolist
# 下载压缩包
[root@centos apache]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
# 查看apr-1.7.0.tar.gz
[root@centos apache]# ll
total 1072
-rw-r--r-- 1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
#解压压缩包
[root@centos apache]# tar -zxvf apr-1.7.0.tar.gz
[root@centos apache]# ll
total 1076
drwxr-xr-x 27 1001 1001    4096 Apr  2  2019 apr-1.7.0
-rw-r--r--  1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
# 进入解压后的文件夹
[root@centos apache]# cd apr-1.7.0
# 创建apr安装目录文件夹
[root@centos apr-1.7.0]# mkdir -p /usr/local/apr/apr
# 安装配置
[root@centos apr-1.7.0]# ./configure --prefix=/usr/local/apr/apr/
# 编译
[root@centos apr-1.7.0]# make
#安装
[root@centos apr-1.7.0]# make install


部分安装过程截图如下:




🟡apr-util安装


下载链接:https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz



[root@centos apache]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
[root@centos apache]# ll
total 1624
drwxr-xr-x 28 1001 1001    4096 Dec 22 18:19 apr-1.7.0
-rw-r--r--  1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
drwxr-xr-x 20 1001 1001    4096 Oct 18  2017 apr-util-1.6.1
-rw-r--r--  1 root root  554301 Jul  6  2020 apr-util-1.6.1.tar.gz
[root@centos apache]#
[root@centos apache]# cd apr-util-1.6.1
[root@centos apr-util-1.6.1]#
[root@centos apr-util-1.6.1]# mkdir /usr/local/apr/util
# --with-apru命令的意思是指定自定义的apr的安装位置
[root@centos apr-util-1.6.1]# ./configure --prefix=/usr/local/apr/util --with-apr=/usr/local/apr/apr
# 编译
[root@centos apr-util-1.6.1]# make
#安装
[root@centos apr-util-1.6.1]# make install


部分安装过程截图如下:



🟢pcre安装


下载链接:https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz/download


[root@centos apache]# ll
total 3672
drwxr-xr-x 28 1001 1001    4096 Dec 22 18:19 apr-1.7.0
-rw-r--r--  1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
drwxr-xr-x 21 1001 1001    4096 Dec 22 18:32 apr-util-1.6.1
-rw-r--r--  1 root root  554301 Jul  6  2020 apr-util-1.6.1.tar.gz
-rw-r--r--  1 root root 2096552 Dec 22 18:39 pcre-8.45.tar.gz
[root@centos apache]#
[root@centos apache]# tar -zxvf pcre-8.45.tar.gz
[root@centos apache]# cd pcre-8.45/
[root@centos pcre-8.45]#mkdir /usr/local/pcre
[root@centos pcre-8.45]# ./configure --prefix=/usr/local/pcre/
[root@centos pcre-8.45]# make
[root@centos pcre-8.45]# make install


部分安装过程截图如下:




3、Apache安装


下载链接:阿里云开源镜像站资源目录 (aliyun.com)



[root@centos ~]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.52.tar.gz
[root@centos apache]# ll
total 13188
drwxr-xr-x 28 1001  1001    4096 Dec 22 18:19 apr-1.7.0
-rw-r--r--  1 root root  1093896 Jul  6  2020 apr-1.7.0.tar.gz
drwxr-xr-x 21 1001  1001    4096 Dec 22 18:32 apr-util-1.6.1
-rw-r--r--  1 root root   554301 Jul  6  2020 apr-util-1.6.1.tar.gz
drwxr-xr-x 12  504 games    4096 Dec 16 21:49 httpd-2.4.52
-rw-r--r--  1 root root  9719976 Dec 20 17:36 httpd-2.4.52.tar.gz
drwxr-xr-x  9 1169  1169   12288 Dec 22 18:45 pcre-8.45
-rw-r--r--  1 root root  2096552 Dec 22 18:39 pcre-8.45.tar.gz
[root@centos apache]# cd httpd-2.4.52
[root@centos httpd-2.4.52]#
[root@centos httpd-2.4.52]# mkdir /usr/local/httpd
[root@centos httpd-2.4.52]# ./configure --prefix=/usr/local/httpd/
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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.
# 因修改了apr的默认安装位置,提示找不到apr,使用帮助命令查看。
[root@centos httpd-2.4.52]# ./configure --help
[root@centos httpd-2.4.52]# ./configure --help | grep -i apr
  --enable-hook-probes    Enable APR hook probes
  --with-included-apr     Use bundled copies of APR/APR-Util
  --with-apr=PATH      prefix for installed APR or the full path to
                             apr-config
  --with-apr-util=PATH prefix for installed APU or the full path to
# 指定自定义的目录
[root@centos httpd-2.4.52]# ./configure --prefix=/usr/local/httpd/ --with-apr=/usr/local/apr/apr/ --with-apr-util=/usr/
local/apr/util/ --with-pcre=/usr/local/pcre/  --with-included-apr
local/apr/util/ --with-pcre=/usr/local/pcre/
# 编译
[root@centos httpd-2.4.52]# make
# 安装
[root@centos httpd-2.4.52]# make install
# 修改配置信息
[root@centos httpd-2.4.52]# vim /usr/local/httpd/conf/httpd.conf
 ServerName localhost:80
 保存退出
# 启动Apache服务
[root@centos ~]# /usr/local/httpd/bin/apachectl -k start
[root@localhost ~]# /usr/local/httpd/bin/apachectl -T
httpd (pid 66510) already running
[root@localhost ~]#
[root@localhost ~]# cd /usr/local/httpd/
[root@localhost httpd]# ll
total 44
drwxr-xr-x  2 root root  302 Dec 22 19:35 bin
drwxr-xr-x  2 root root  253 Dec 22 19:35 build
drwxr-xr-x  2 root root   78 Dec 22 19:10 cgi-bin
drwxr-xr-x  4 root root   84 Dec 22 19:47 conf
drwxr-xr-x  3 root root 4096 Dec 22 19:10 error
drwxr-xr-x  2 root root   24 Dec 22 19:10 htdocs
drwxr-xr-x  3 root root 8192 Dec 22 19:10 icons
drwxr-xr-x  2 root root 8192 Dec 22 19:35 include
drwxr-xr-x  3 root root  281 Dec 22 19:35 lib
drwxr-xr-x  2 root root   58 Dec 22 19:55 logs
drwxr-xr-x  4 root root   30 Dec 22 19:10 man
drwxr-xr-x 14 root root 8192 Dec 22 19:10 manual
drwxr-xr-x  2 root root 4096 Dec 22 19:35 modules
[root@localhost httpd]# cd htdocs/
[root@localhost htdocs]# ll
total 4
-rw-r--r-- 1 504 games 45 Jun 12  2007 index.html
[root@localhost htdocs]# cat index.html
<html><body><h1>It works!</h1></body></html>
[root@localhost htdocs]#


部分安装过程截图如下:






四、总结与反馈


以上就是编译安装Apache的主要操作步骤,需要注意的是在安装Apache之前,需要安装好相应的依赖包,否则会在安装过程中报错,需要进一步排查。


在安装相应的依赖包的过程中,也会发生一些报错,也需要安装相应的组件,可以将报错信息复制粘贴至网上,搜索查看对应的解决办法。


这里也罗列了几个在安装过程中报错的信息,供大家参考。


报错信息1


# 报错信息
[root@centos apr-1.7.0]# ./configure --prefix=/usr/local/apr/apr/
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
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.0
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/apache/apr-1.7.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@centos apr-1.7.0]#
[root@centos apr-1.7.0]# yum -y install gcc
参考链接:https://blog.csdn.net/weixin_33858249/article/details/91574176


报错信息2


# 报错信息2
[root@centos apr-util-1.6.1]# make
make[1]: Entering directory `/root/apache/apr-util-1.6.1'
/bin/sh /usr/local/apr/apr//build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/root/apache/apr-util-1.6.1/include -I/root/apache/apr-util-1.6.1/include/private  -I/usr/local/apr/apr//include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
 #include <expat.h>
                   ^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/apache/apr-util-1.6.1'
make: *** [all-recursive] Error 1
# 解决办法
[root@centos apr-util-1.6.1]# yum install -y expat-devel
参考链接:https://blog.csdn.net/weixin_43930641/article/details/105269092


报错信息3


checking for windows.h... no
configure: error: Invalid C++ compiler or C++ compiler flags
# yum install -y gcc-c++
参考链接:https://blog.csdn.net/weixin_43930641/article/details/105313937


报错信息3


checking for windows.h... no
configure: error: Invalid C++ compiler or C++ compiler flags
# yum install -y gcc-c++
参考链接:https://blog.csdn.net/weixin_43930641/article/details/105313937
相关文章
|
20天前
|
存储 消息中间件 人工智能
AI大模型独角兽 MiniMax 基于阿里云数据库 SelectDB 版内核 Apache Doris 升级日志系统,PB 数据秒级查询响应
早期 MiniMax 基于 Grafana Loki 构建了日志系统,在资源消耗、写入性能及系统稳定性上都面临巨大的挑战。为此 MiniMax 开始寻找全新的日志系统方案,并基于阿里云数据库 SelectDB 版内核 Apache Doris 升级了日志系统,新系统已接入 MiniMax 内部所有业务线日志数据,数据规模为 PB 级, 整体可用性达到 99.9% 以上,10 亿级日志数据的检索速度可实现秒级响应。
AI大模型独角兽 MiniMax 基于阿里云数据库 SelectDB 版内核 Apache Doris 升级日志系统,PB 数据秒级查询响应
|
20天前
|
关系型数据库 MySQL 应用服务中间件
win7系统搭建PHP+Mysql+Apache环境+部署ecshop项目
这篇文章介绍了如何在Windows 7系统上搭建PHP、MySQL和Apache环境,并部署ECShop项目,包括安装配置步骤、解决常见问题以及使用XAMPP集成环境的替代方案。
34 1
win7系统搭建PHP+Mysql+Apache环境+部署ecshop项目
|
27天前
|
Ubuntu 关系型数据库 MySQL
在 Ubuntu 14.04 服务器上使用 Apache 安装 Drupal 的方法
在 Ubuntu 14.04 服务器上使用 Apache 安装 Drupal 的方法
16 0
|
27天前
|
存储 缓存 Ubuntu
如何在 Apache Web 服务器中安装、配置和使用模块
如何在 Apache Web 服务器中安装、配置和使用模块
46 0
|
27天前
|
Ubuntu Java 应用服务中间件
在Ubuntu 16.04上安装Apache Tomcat 8的方法
在Ubuntu 16.04上安装Apache Tomcat 8的方法
13 0
|
27天前
|
安全 Java 应用服务中间件
在CentOS 7上安装Apache Tomcat 8的方法
在CentOS 7上安装Apache Tomcat 8的方法
41 0
|
17天前
|
存储 消息中间件 Java
Apache Flink 实践问题之原生TM UI日志问题如何解决
Apache Flink 实践问题之原生TM UI日志问题如何解决
29 1
|
Java 应用服务中间件 Shell
|
14天前
|
消息中间件 监控 数据挖掘
基于RabbitMQ与Apache Flink构建实时分析系统
【8月更文第28天】本文将介绍如何利用RabbitMQ作为数据源,结合Apache Flink进行实时数据分析。我们将构建一个简单的实时分析系统,该系统能够接收来自不同来源的数据,对数据进行实时处理,并将结果输出到另一个队列或存储系统中。
59 2
|
17天前
|
消息中间件 分布式计算 Hadoop
Apache Flink 实践问题之Flume与Hadoop之间的物理墙问题如何解决
Apache Flink 实践问题之Flume与Hadoop之间的物理墙问题如何解决
30 3

推荐镜像

更多