`

Linux系统安装Apache 2.4.6

 
阅读更多

Apache简介

 

        Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。关于更多Apache的介绍,可以参考百科“http://baike.baidu.com/view/28283.htm或官网http://www.apache.org/ 或 http://httpd.apache.org/的介绍

 

Apache软件下载

  Apache的相关软件包下载地址http://apr.apache.org/projects.html

1.   Apache HTTP Server

    截止目前为止,Apache HTTP Server 目前最新的版本是 Apache httpd 2.4.6 Released, 下载地址:http://httpd.apache.org/download.cgi#apache24

2.   APR and APR-Util包

    截止目前为止,APR and APR-Util的最新版本如下,下载地址:http://apr.apache.org/download.cgi

  • APR 1.4.8, released June 21, 2013
  • APR-util 1.5.2, released April 4, 2013
  • APR-iconv 1.2.1, released November 26, 2007

3.   PCRE包

   截止目前为止,PCRE最新的包为8.33,下载地址如下

 

  可以下载了相关安装包,上传到/root/kerry这个临时目录。也可以直接通过wget下载

Apache安装要求

下面是官方文档的要求,必须安装APR、APR-Util、PCRE,gcc-c++等包,文档URL地址http://httpd.apache.org/docs/2.4/install.html

 

Requirements

The following requirements exist for building Apache httpd:

APR and APR-Util

Make sure you have APR and APR-Util already installed on your system. If you don't, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be sure the directory names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/) and use ./configure's --with-included-apr option. On some platforms, you may have to install the corresponding -dev packages to allow httpd to build against your installed copy of APR and APR-Util.

Perl-Compatible Regular Expressions Library (PCRE)

This library is required but not longer bundled with httpd. Download the source code from http://www.pcre.org, or install a Port or Package. If your build system can't find the pcre-config script installed by the PCRE build, point to it using the --with-pcre parameter. On some platforms, you may have to install the corresponding -dev package to allow httpd to build against your installed copy of PCRE.

Disk Space

Make sure you have at least 50 MB of temporary free disk space available. After installation the server occupies approximately 10 MB of disk space. The actual disk space requirements will vary considerably based on your chosen configuration options, any third-party modules, and, of course, the size of the web site or sites that you have on the server.

ANSI-C Compiler and Build System

Make sure you have an ANSI-C compiler installed. The GNU C compiler (GCC) from the Free Software Foundation (FSF) is recommended. If you don't have GCC then at least make sure your vendor's compiler is ANSI compliant. In addition, your PATH must contain basic build tools such as make.

Accurate time keeping

Elements of the HTTP protocol are expressed as the time of day. So, it's time to investigate setting some time synchronization facility on your system. Usually thentpdate or xntpd programs are used for this purpose which are based on the Network Time Protocol (NTP). See the NTP homepage for more details about NTP software and public time servers.

Perl 5 [OPTIONAL]

For some of the support scripts like apxs or dbmmanage (which are written in Perl) the Perl 5 interpreter is required (versions 5.003 or newer are sufficient). If you have multiple Perl interpreters (for example, a systemwide install of Perl 4, and your own install of Perl 5), you are advised to use the --with-perl option (see below) to make sure the correct one is used by configure. If no Perl 5 interpreter is found by the configure script, you will not be able to use the affected support scripts. Of course, you will still be able to build and use Apache httpd.

 

Apache安装过程

 

Step 1:安装包gccgcc-c++

[root@getlnx05 pcre-8.33]# yum list gcc-c++

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Available Packages

gcc-c++.x86_64                                                               4.1.2-51.el5                                                                rhel-debuginfo

[root@getlnx05 pcre-8.33]# yum list gcc

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Installed Packages

gcc.x86_64                                                                    4.1.2-51.el5                                                                    installed

[root@getlnx05 pcre-8.33]# rpm -q gcc

gcc-4.1.2-51.el5

从上面可见gcc包已经安装,缺少gcc-c++包,那么接下来安装包gcc-c++,如果此处不安装该包,后面安装过程中会报错

[root@getlnx05 pcre-8.33]#yum install  gcc-c++

 

Step 2:安装包APRAPR-Util

[root@getlnx05 kerry]# ls apr*

apr-1.4.8.tar.gz  apr-util-1.5.2.tar.gz

[root@getlnx05 kerry]#

[root@getlnx05 kerry]# tar -zxf apr-1.4.8.tar.gz

[root@getlnx05 kerry]# cd apr-1.4.8

[root@getlnx05 apr-1.4.8]# ls

clip_image002

新建目录/usr/local/apr,用作安装目录:

[root@getlnx05 apr-1.4.8]# mkdir /usr/local/apr

[root@getlnx05 apr-1.4.8]# ./configure --prefix=/usr/local/apr

clip_image004

[root@getlnx05 apr-1.4.8]# make

[root@getlnx05 apr-1.4.8]# make install

clip_image006

安装完成后,可以验证一下

[ root@getlnx05 apr]# ls -lrt

total 32

drwxr-xr-x 3 root root 4096 Aug 15 06:57 include

drwxr-xr-x 3 root root 4096 Aug 15 06:57 lib

drwxr-xr-x 2 root root 4096 Aug 15 06:57 build-1

drwxr-xr-x 2 root root 4096 Aug 15 06:57 bin

[root@getlnx05 kerry]# mkdir /usr/local/apr-util

[root@getlnx05 kerry]# tar -zxf apr-util-1.5.2.tar.gz

[root@getlnx05 kerry]# cd apr-util-1.5.2

clip_image008

[root@getlnx05 apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

clip_image010

[root@getlnx05 apr-util-1.5.2]# make

[root@getlnx05 apr-util-1.5.2]# make install

clip_image012

 

Step 3:安装包PRCE

[root@getlnx05 kerry]# unzip pcre-8.33.zip

[root@getlnx05 kerry]# cd pcre-8.33

[root@getlnx05 kerry]#mkdir /usr/local/pcre

[root@getlnx05 pcre-8.33]# ./configure --prefix= /usr/local/pcre--with-apr=/usr/local/apr/bin/apr-1-config

clip_image014

[root@getlnx05 pcre-8.33]# make

[root@getlnx05 pcre-8.33]# make install

clip_image016

 

Step 4:安装Apache Http Server

[root@getlnx05 kerry]# tar zxvf httpd-2.4.6.tar.gz

[root@getlnx05  kerry]#cd httpd-2.4.6

[root@getlnx05 httpd-2.4.6]# ./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

[root@getlnx05 httpd-2.4.6]#make

[root@getlnx05 httpd-2.4.6]#make install

Step 5:启动Apache服务

[root@getlnx05 httpd-2.4.6]#  /usr/local/apache/bin/apachectl start

用浏览器访问http://localhost时提示It works!

 

 

Apache安装问题锦集

 

问题1:缺少包gcc-c++导致安装包apr-util不通过

 

[root@getlnx05 kerry]# unzip pcre-8.33.zip

[root@getlnx05 kerry]# cd pcre-8.33

[root@getlnx05 pcre-8.33]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config

clip_image018

一般出现这个错误是因为没有安装包gcc-c++,可以通过如下命令检查,

[root@getlnx05 pcre-8.33]# yum list gcc-c++

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Available Packages

gcc-c++.x86_64                                                               4.1.2-51.el5                                                                rhel-debuginfo

[root@getlnx05 pcre-8.33]# yum list gcc

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Installed Packages

gcc.x86_64                                                                    4.1.2-51.el5                                                                    installed

[root@getlnx05 pcre-8.33]# rpm -q gcc

gcc-4.1.2-51.el5

[root@getlnx05 pcre-8.33]# rpm -q gcc-c++

 

问题2:checking for APR-util... configure: error: the --with-apr-util parameter is incorrect

[root@getlnx05 httpd-2.4.6]#  ./configure --prefix=/usr/local/apache  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

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-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 " -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... configure: error: the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file.

[root@getlnx05 httpd-2.4.6]#

一般是由于APR-util没有安装成功,可以通过验证该目录是否为空来判断,因为你有时候执行了make,忘了执行make isntall命令有可能导致这个错误。

[root@getlnx05 apr]# cd /usr/local/apr-util

[root@getlnx05 apr-util]# ls

 

问题3:没有指定PCRE参数

[root@getlnx05 httpd-2.4.6]#  ./configure --prefix=/usr/local/apache  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

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-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 " -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... yes

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking how to run the C preprocessor... gcc -E

checking for gcc option to accept ISO C99... -std=gnu99

checking for pcre-config... false

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

[root@getlnx05 httpd-2.4.6]#

 

问题4:安装前忘了先安装APR相关包

[root@getlnx05 httpd-2.4.6]#  ./configure --prefix=/usr/local/appache/

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-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@getlnx05 httpd-2.4.6]#

 

问题5:启动服务时报错

[root@getlnx05 httpd-2.4.6]#  /usr/local/apache/bin/apachectl start

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using getlnx05.gfg1.esquel.com. Set the 'ServerName' directive globally to suppress this message

这个时候需要编辑httpd.conf配置文件,添加SeraverName的具体IP地址。如下所示

[root@getlnx05 conf]# cd /usr/local/apache/conf/

[root@getlnx05 conf]# ls

extra  httpd.conf  magic  mime.types  original

[root@getlnx05 conf]# vi httpd.conf

ServerAdmin you@example.com

#

# ServerName gives the name and port that the server uses to identify itself.

# This can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#

# If your host doesn't have a registered DNS name, enter its IP address here.

#

#ServerName www.example.com:80

ServerName 192.168.9.122:80

#

# Deny access to the entirety of your server's filesystem. You must

# explicitly permit access to web content directories in other

# <Directory> blocks below.

#

"httpd.conf" 502L, 18179C written

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

httpd not running, trying to start

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl start

httpd (pid 7797) already running

如果从其它电脑连接访问Apache时,输入url地址:http://192.168.9.122页面没有显示正常,而上面配置也OK,那么你必须关闭防火墙,有时候甚至需要重启电脑才能OK,重启Apache服务都无效。

[root@getlnx05 conf]# chkconfig iptables off

[root@getlnx05 conf]# chkconfig iptables off

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

[root@getlnx05 conf]#

 

 

文献出处:http://www.cnblogs.com/kerrycode/p/3261101.html

分享到:
评论

相关推荐

    Apache2.4.6在Linux中安装及配置自启动

    本教程将详细阐述如何在Linux环境中安装Apache2.4.6并设置其自启动,以确保服务器在系统启动时自动运行。 首先,我们需要确保系统已经安装了必要的开发工具和依赖库。在基于Red Hat的系统(如CentOS)上,可以使用...

    apache httpd2.4.6 for linux

    总的来说,Apache HTTPD 2.4.6是针对Linux系统的强大Web服务器解决方案,其优化的性能、安全特性以及灵活性,使其成为开发和部署Web应用的理想选择。在安装和使用httpd-2.4.6压缩包时,用户应仔细阅读文档,正确配置...

    Linux CentOS离线环境下安装Apache所需要的完整包

    在Linux CentOS离线环境下安装Apache服务器,特别是在没有网络连接的情况下,需要手动下载并准备所有必要的依赖包。这个压缩包文件提供了在这样的环境中成功安装Apache及其扩展模块mod_wsgi所需的所有组件。下面将...

    apache http server在linux上的安装

    本文将指导您如何在 Redhat Linux 5.6 X64 系统上安装 Apache HTTP Server 2.4.6。 在开始安装之前,需要安装一些必要的依赖项,包括 GCC 和 Make 等。使用 yum 安装这些依赖项: ``` # yum –y install gcc # yum ...

    Linux服务器配置与管理:Apache服务器安装配置.pptx

    在Linux服务器配置与管理中,掌握Apache服务器的安装配置是运维人员的基本技能。以下是对Apache服务器安装配置的详细说明: 1. **Apache软件包**: - `httpd-2.4.6-45.el7.x86_64.rpm`:这是Apache服务器的主要...

    Apache全套Linux安装包(apr,apr-util,pcre)

    Apache全套安装包(apr,apr-util,pcre) 适用于Linux系统。 包含了安装Apache的web服务器的全套软件。 免得你一个个去网上搜索下载的...具体安装方式请参考我的下载资源,搜索“Apache2.4.6在Linux中安装及配置自启动”

    Apache linux下部署

    本文将详细介绍如何在Linux系统上安装和配置Apache Web服务器。 1. **安装Apache服务** - 在Linux系统中安装Apache通常通过包管理器进行。例如,在基于Red Hat的发行版中,可以使用`yum`命令来安装Apache Web...

    linux上apache源码安装

    在Linux上进行源码安装Apache可以帮助我们自定义配置并获取最新版本的功能。以下是基于源码安装Apache的详细步骤,以及相关的知识点。 1. **依赖库安装** Apache 2.3.x及以上版本不再集成PCRE(Perl Compatible ...

    centos7Centos7操作系统搭建Snipe-IT资产管理系统.docx

    Centos 7.6是此系统搭建的操作系统,Apache 2.4.6是Web服务器,PHP 7.2是脚本语言,Mariadb 5.5.60是数据库管理系统。环境准备完成后,需要更新系统、安装Apache、Mariadb和PHP,并对PHP进行源码编译安装。 Snipe-...

    安装Apache提示缺少 libapr-1.so.0与libaprutil-1完美解决

    当Apache的安装脚本检测到系统中没有这些关键库时,会抛出错误并阻止安装过程继续进行。这通常发生在以下几种情况: 1. **未安装依赖包**:在初次安装Apache或升级Apache版本时,如果没有正确安装或更新相关的依赖...

    Centos 7.4 LAMP架构_部署 glpi 9.4.3.docx

    Apache 2.4.6 提供了高性能、可扩展和安全的 web 服务器环境,支持多种编程语言和数据库系统。 四、PHP 7.1.33 PHP 7.1.33 是一个开源的服务器端脚本语言,广泛应用于 Web 应用程序开发。PHP 7.1.33 提供了高性能...

    httpd在centos7.6下的离线安装包

    标题 "httpd在centos7.6下的离线安装包" 涉及的是在CentOS 7.6操作系统上安装Apache HTTP服务器的过程,而离线安装意味着我们不会通过网络YUM仓库进行安装,而是使用预先下载的RPM包。这通常在没有稳定网络连接或者...

    CentOS 卸载 Apache

    在 Linux 系统中,Apache 是一个非常流行的 Web 服务器软件,但是有时候我们可能需要卸载它,以释放系统资源或更换为其他软件。在 CentOS 系统中,卸载 Apache 可以通过以下步骤完成。 查看 Apache 版本 在卸载 ...

    Centos7安装给Apache服务安装配置SSL证书

    一、目标 在Centos7.6平台下使用openssl给apache做自签名证书,并给apache...CentOS Linux release 7.6.1810 (Core)  [root@kahn.xiao ~]# rpm -qa |grep httpd httpd-tools-2.4.6-90.el7.centos.x86_64 httpd-2.4.6-9

    apache编译移植步骤

    Apache编译移植到NXP i.MX6Q A9 ARM处理器上的Linux4.1.15系统是一项复杂的工作,需要对嵌入式系统、编译工具链以及Apache服务器有深入理解。以下是对整个过程的详细解释: 1. **下载源码**: 首先,你需要获取...

    Linux+Apache+Mysql+PHP典型配置.pdf

    总结,Linux+Apache+MySQL+PHP的配置涉及到多个步骤,包括软件下载、安装、配置和安全优化。理解每个组件的功能和配置选项,将有助于构建一个稳定、高效的Web服务器环境。在实际操作过程中,遇到问题应查看日志文件...

    httpd-2.4.6-80.el7.centos.x86_64.rpm

    rhel7和centos7 64位版本安装apache服务,httpd 2.4.6 rpm直装包。

    Linux部署Zabbix,包括目标机安装Agent.

    ### Linux部署Zabbix,包括目标机安装Agent #### 一、Zabbix概述 Zabbix是一款企业级的开源监控工具,其主要功能在于提供对分布式系统的监视及网络监控服务。通过Zabbix,用户能够实时监测各类网络参数,确保...

    httpd-2.4.6-97.el7.centos.2.x86_64.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

Global site tag (gtag.js) - Google Analytics