apache编译安装

apache是什么:

    Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩充,将Perl/Python解释器编译到服务器中。同时Apache音译为阿帕奇,是北美印第安人的一个部落,叫阿帕奇族,在美国的西南部。也是一个基金会的名称、一种武装直升机等等。


今天尝试着安装apache,要求能访问,库文件和软链接,还有man帮助暂不阐述

前言:安装apache之前,检查gcc编译器是否安装

[root@localhost tmp]# rpm -qa |grep gcc
libgcc-4.4.7-17.el6.x86_64
gcc-4.4.7-17.el6.x86_64

我这里已经装过,没安装的话使用yum -y install gcc安装。

1、从apacha官网下载httpd包,http://apache.fayea.com/httpd  解压并cd到子目录:

[root@localhost ~]# tar -xf httpd-2.4.10.tar.bz2 
[root@localhost ~]# cd httpd-2.4.10
[root@localhost httpd-2.4.10]#

执行./configure,指定安装路径/usr/local/apache2

[root@localhost httpd-2.4.10]# ./configure --prefix=/usr/local/apache2
..
    
checking for APR... no
configure: error: APR not found.  Please read the documentation.
[root@localhost httpd-2.4.10]#

发现报错,提示没有找到APR的路径,从http://apache.fayea.com/apr/ 下载源码包apr,解压并cd到子目录

[root@localhost ~]# tar -xf apr-1.5.0.tar.bz2 
[root@localhost ~]# cd apr-1.5.0
[root@localhost apr-1.5.0]# ./configure --prefix=/usr/local/apr/
没有报错,继续安装
[root@localhost apr-1.5.0]# make && make install 
没有报错,安装成功!

2、再次安装httpd包,指定apr路径

[root@localhost httpd-2.4.10]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/
..
configure: 
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.
[root@localhost httpd-2.4.10]#

发现缺少apr-util包,从http://apache.fayea.com/apr/下载apr-util包,解压后cd到子目录,执行./confgure 指定apr路径,顺便make和make install

[root@localhost apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ && make && make install
..
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util//lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util//bin/apu-1-config
[root@localhost apr-util-1.5.3]# 
成功安装,没有报错

3.再次尝试安装httpd包,提示缺少pcre包

[root@localhost httpd-2.4.10]# ./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ 
\--with-apr-util=/usr/local/apr-util/
..
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@localhost httpd-2.4.10]#

从提示信息的官网下载pcre包 http://pcre.org,解压,cd到子目录,指定apr和apr-util安装路径    

[root@localhost pcre-8.38]# ./configure --prefix=/usr/local/pcre/ --with-apr=/usr/local/apr/ 
\--with-apr-util=/usr/local/apr-util/
..
checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.

这里提示我没有安装C++编译器,yum安装

[root@localhost pcre-8.38]# yum -y install gcc-c++

再次安装pcre

[root@localhost pcre-8.38]# ./configure --prefix=/usr/local/pcre/ --with-apr=/usr/local/apr/ 
\--with-apr-util=/usr/local/apr-util/
[root@localhost pcre-8.38]# make && make install

4、最后安装httpd包,指定apr,apr-util,pcre 路径

[root@localhost httpd-2.4.10]# ./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ 
\--with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
..
[root@localhost httpd-2.4.10]# make && make install
mkdir /usr/local/apache2/manual
make[1]: Leaving directory `/root/httpd-2.4.10'
[root@localhost httpd-2.4.10]#

买有什么报错,启动服务

[root@localhost httpd-2.4.10]# /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, 
\using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost httpd-2.4.10]#

这里有个报错,提示主机名有问题,没什么大碍,不用管它,去网页检测一下

成功了。若访问不了,可能是防火墙的原因,iptables -F关闭它。

提示:在编译安装过程中,一定要cd 到解压之后的包目录,再执行./confgure 等操作。

001.png








原创文章,作者:M20-1--孔祥文,如若转载,请注明出处:http://www.178linux.com/39702

(0)
M20-1--孔祥文M20-1--孔祥文
上一篇 2016-08-24 21:22
下一篇 2016-08-24 21:22

相关推荐

  • 文件管理

    compress:压缩命令 -d:解压缩(=uncompress) -c:结果输出到标准输出,不删除原文件 -v:显示详情 zcat:不解压文件查看内容   gzip:压缩命令 -d:解压缩 -c:结果输出到标准输出,不删除原文件 -#:1-9代表压缩比,默认为6 zcat:不解压文件查看内容   bzip2:压缩命令 -k:保留原文件 …

    Linux干货 2016-08-18
  • CentOS6下的网络信息配置

    简介     我们都知道在我们互联网中,所有的通信都通过网络来完成的,有了网络当然也要有对应的地址,MAC地址是固定不变的,所以能变的只有IP的地址,那么今天来带给大家如何在CentOS6中如何配置网卡。当然一下的所有命令都是在CentOS6中进行的。 一、网卡的配置文件    1.操作网卡的命令 …

    Linux干货 2017-03-20
  • 开篇

    正式开始学习的第一天,了解LINUX,爱上LINUX。希望在往后的日子里越战越勇!!

    Linux干货 2017-07-11
  • 马哥linux2014|2015全套教程

    1、本课程全程将基于集成了Openstack云环境、支持高精度时间(PTP)及虚拟化性能大大提升的RHEL 6.5或CentOS 6.6,间或介绍CentOS 7系统的使用; 2、此文章给出的只是个课程知识点框架,实际讲解过程相当精细;另外,知识点讲授的次序未必同此文章所标示的顺序相同; 3、第15期面授班定于2015年3月24号开课;本期将会是马哥教育数年…

    Linux干货 2015-07-14
  • 01

    0101

    Linux干货 2016-08-08