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
下一篇 2016-08-24

相关推荐

  • 简单的bash脚本查看任意网段的在线主机

    一前言         最近看到许多同志在写ping某个地址段的bash脚本,我也心血来潮来了一发。  当然本人新手,大神勿喷。 二准备工作           linux系统的机…

    2017-03-02
  • 记马哥教育第30期Linux云计算面授班开班典礼

    记马哥教育第30期Linux云计算面授班开班典礼

    2018-03-26
  • rsyslog记录日志于mysql

    rsyslog记录日志于mysql:     前提:准备好msql server或mariadb server;     (1) 安装rsyslog连接至mysql server的驱动模块;        &n…

    Linux干货 2016-12-05
  • Linux进程篇16.0

    Linux进程介绍

    Linux干货 2017-12-18
  • Net25-第9周作业

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash for line in `cat /etc/passwd`;do if [[ `echo $line | awk -F: ‘{print $7}’` == ‘/sb…

    Linux干货 2017-03-15
  • CentOS程序包管理

    对于Linux系统而言,其能执行的程序为二进制格式,而对于程序开发者而言,直接利用二进制开发程序是不太现实的,所以一般都是利用高级语言来进行软件开发,其程序也即称为源代码;那么我们在对一个程序进行安装、升级、卸载、 查询、校验等操作时,需要对每个源代码进行编译成为二进制程序,那么显然是不太现实的。所以在各Linux发行版中一般都带有程序包管理器。 所谓程序包…

    Linux干货 2016-08-25