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:安装包gcc或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
从上面可见gcc包已经安装,缺少gcc-c++包,那么接下来安装包gcc-c++,如果此处不安装该包,后面安装过程中会报错
[root@getlnx05 pcre-8.33]#yum install gcc-c++
Step 2:安装包APR和APR-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
新建目录/usr/local/apr,用作安装目录:
[root@getlnx05 apr-1.4.8]# mkdir /usr/local/apr
[root@getlnx05 apr-1.4.8]# ./configure --prefix=/usr/local/apr
[root@getlnx05 apr-1.4.8]# make
[root@getlnx05 apr-1.4.8]# make install
安装完成后,可以验证一下
[ 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
[root@getlnx05 apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@getlnx05 apr-util-1.5.2]# make
[root@getlnx05 apr-util-1.5.2]# make install
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
[root@getlnx05 pcre-8.33]# make
[root@getlnx05 pcre-8.33]# make install
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
一般出现这个错误是因为没有安装包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]#
Linux系统安装Apache 2.4.6的更多相关文章
- Linux系统安装Apache
一,Apache和tomcat的区别与联系 apache是web服务器,web服务器专门处理http请求: tomcat是运行在apache上的应用服务器: apache是普通服务器,本身只支持htm ...
- linux系统安装apache服务器
命令行下安装: sudo apt-get install apache2 安装完毕以后, 打开127.0.0.1,可以看到首页: 静态页面的路径是: /var/www/html 作者: NONO 出处 ...
- LNMP平台搭建---Linux系统安装篇
在互联网网站开发领域,有一个名词,大家一定不陌生,那就是LAMP,经典的Web服务器环境,由Linux+Apache+MySQL+PHP组成,,后来,一个名叫Nginx的Web服务器开源出来了,因其更 ...
- linux 下apache安装、启动和配置
linux 下 apache安装 1:系统安装,这里就不说了,网上有很多,也很简单.顺便说下,我用的是redhat 9: 2:在图形界面下下载apache 安装包,我下的是 httpd-2.2.9.t ...
- 阿里云服务器Linux系统安装配置ElasticSearch搜索引擎
近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...
- linux系统安装(上)
1.VMware虚拟机的软件应用 www.vmware.com 2.linux系统安装设置(分区为重点) 3.远程登录管理工具介绍centOS5.5 使用虚拟机的优点 1.不用分区 2.可以完成本机与 ...
- 1.Linux系统安装
Linux系统安装系统分区(磁盘分区) 主要管理:文件和目录分类:主分区:最多有4个 扩展分区:1个扩展分区 和主分区最多4个 存放逻辑分区 逻辑分区:存放数据 格式化:高级格式化(逻辑格式化) 写入 ...
- linux 下 apache相关;启动、停止、重启命令;配置文件位置等等
linux 下 apache启动.停止.重启命 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/usr/l ...
- Linux下apache+phppgadmin+postgresql安装配置
Linux下apache+phppgadmin+postgresql安装配置 操作系统:CentOS 安装包:httpd(首选yum), php(包括php以及php-pgsql,php-mbstri ...
随机推荐
- ZOJ Problem Set - 1216 Deck
#include <stdio.h> int main() { ]; double t=2.0; table[]=0.5; ;i<;i++) { t+=; table[i]=tabl ...
- 关于Java中的transient关键字
Java中的transient关键字是在序列化时候用的,如果用transient修饰变量,那么该变量不会被序列化. 下面的例子中创建了一个Student类,有三个成员变量:id,name,age.ag ...
- C#运用GmaQrCode生成二维码
项目中需要生成二维码,方法比较多,可以采用JS插件,也可以采用第三方插件后台生成二维码,在后台方法中可以采用QRCode或者GmaQrCode,现在介绍一种C#在后台生成二维码的方法: /// < ...
- 【面试】输出"蛇形"矩阵
一.题目描述 腾讯实习在线笔试的一道题目. 根据输入的数字(< 1000),输出这样的"蛇形"矩阵,如下.输入n,输出(n * n)阶矩阵,满足由外到内依次增大. 如: 输入 ...
- Azure Application Gateway (2) 面向公网的Application Gateway
<Windows Azure Platform 系列文章目录> 本章将介绍如何创建面向公网的Application Gateway,我们需要准备以下工作: 1.创建新的Azure Reso ...
- JS产生随机数的几个用法!
<script> function GetRandomNum(Min,Max) { var Range = Max - Min; var Rand = Math.random(); ret ...
- [Q&A] 在证书存储区中找不到清单签名证书
方案1:右击项目属性->签名->为 ClickOnce 清单签名,将勾掉的选项去掉. 方案2:在签名中创建一个新的签名. 方案3:记事本打开相应的 csproj 文件,调整节点值.< ...
- [C#] .NET4.0中使用4.5中的 async/await 功能实现异
好东西需要分享 原文出自:http://www.itnose.net/detail/6091186.html 在.NET Framework 4.5中添加了新的异步操作库,但是在.NET Framew ...
- Windows Server 2008设置远程桌面连接的最大数量
远程桌面连接的默认数量是2,当有多个用户需要同时远程桌面连接时很不方便,可以设置远程桌面连接的最大数量. 1. 运行gpedit.msc: 2. 选择计算机配置-->管理模板-->Wind ...
- SpringMVC中的异常处理集锦
1 描述 在J2EE项目的开发中,不管是对底层的数据库操作过程,还是业务层的处理过程,还是控制层的处理过程,都不可避免会遇到各种可预知的.不可预知的异常需要处理.每个过程都单独处理异常,系统的代码耦合 ...