Linux上安装Apache环境及安装过程报错解决方案(零初始环境)

news/2024/7/7 10:30:03

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Note:要从零开始搭建,就不要嫌中间遇到各种eggache的问题!

一.下载apache源代码

1.下载地址:http://httpd.apache.org/download.cgi  找稳定的最新的版本(Stable Release)

   得到文件 httpd-2.4.3.tar.gz

2. 上传到你的服务器目录,如:/home/tnuser/installers

    解压:tar -zxvf httpd-2.4.3.tar.gz   (我们下载的是源代码,所以这一步只是把源代码解压) 

    移动解压后的目录到目标地址:mv /home/tnuser/installers/httpd-2.4.3  /home/tnuser/  (这一步只是把解压后的目录放在合适的位置方便管理,可以不做)

3. 接下来我们需要编译刚才解压的源文件,这是重点

     配置编译时的一些参数: 

[plain]  view plain copy print ?
  1. cd  /home/tnuser/installers/httpd-2.4.3  (切换到apache源代码目录下)  
  2.   
  3.  ./configure --prefix=/home/tnuser/apache/   (设置apache安装目录,这里的 /home/tnuser/apache/ 才是apache真正的安装目录)  

二. 到这里时,回车运行命令,报错:

如果你能正常执行,说明你以前安装过apache环境,请直接make & make install 并请跳过下面一段

checking for APR... no
configure: error: APR not found.  Please read the documentation.

解决方案:

Apache在安装时需要一些准备环境,这里需要安装另外一个东西 APR(Apache Portable Runtime)。

下载地址: http://archive.apache.org/dist/apr/ 同样找最新版本

得到文件:apr-1.4.6.tar.gz

解压:tar -zxvf apr-1.4.6.tar.gz

编译:

[plain]  view plain copy print ?
  1. cd /home/tnuser/installers/apr-1.4.6  
  2.   
  3.  ./configure --prefix=/home/tnuser/apr/  (一堆日志信息)  
  4.   
  5. make (一堆日志信息)  
  6.   
  7. make install (一堆日志信息)  

完成后在指定地址生成目录和文件

接着装apache,切换到源代码目录设置编译参数: ./configure --prefix=/home/tnuser/apache/ 

还是报上面的错,这是因为上面自定义了apr的安装目录,所以得把这个信息告诉apache。

正确的运行命令为:

[plain]  view plain copy print ?
  1. ./configure --prefix=/home/tnuser/apache/  --with-apr=/home/tnuser/apr/  

三. 执行后继续报错

不过这次错误信息变成了:(不要紧,这说明你的apr安装好了,只是又发现少了另外一个环境,慢慢来)

checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.

解决方案: 下载 APR-util

下载地址:http://archive.apache.org/dist/apr/ 找最新版本

得到文件:apr-util-1.5.1.tar.gz

解压: tar -zxvf apr-util-1.5.1.tar.gz

编译:

[plain]  view plain copy print ?
  1. cd /home/tnuser/installers/apr-util-1.5.1  
  2.   
  3.  ./configure --prefix=/home/tnuser/apr-util/   

这次运行会报错:

checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.

看到提示你就懂了,不多说:

[plain]  view plain copy print ?
  1. ./configure --prefix=/home/tnuser/apr-util/ --with-apr=/home/tnuser/apr/  
  2.   
  3.  make  
  4.   
  5.  make install   

在你指定的安装地址生成目录就说明安装成功了


四. 再转回去继续安装apache

有了上回的经验,这次就知道运行什么命令了。切到apache源代码目录下运行:

[plain]  view plain copy print ?
  1. ./configure --prefix=/home/tnuser/apache/  --with-apr=/home/tnuser/apr/  --with-apr-util=/home/tnuser/apr-util/  
照旧报错:

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

解决方案:发现还是少环境,不多说,下载 PCRE

下载地址: http://jaist.dl.sourceforge.net/project/pcre/pcre/ 找最新版下

得到文件: pcre-8.32.tar.gz

解压:tar -zxvf pcre-8.32.tar.gz

编译:

[plain]  view plain copy print ?
  1. cd /home/tnuser/hunter/installers/pcre-8.32  
  2.   
  3. ./configure --prefix=/home/tnuser/pcre/  

这次错误信息如下:

checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.

原来pcre需要用C++编译(我只想说:Why I need C++ while I'm a java programmer? Eggache! Holy Shit!)

解决方案:

首先,区分你的系统是Debian还是Fedora。

我的系统是Fedora,所以配置步骤如下:(Debian系统使用命令apt-get,对应工具包为build-essential,命令使用方法:apt-get install build-essential)

sudo yum groupinstall "Development Tools"

这里会花费很长时间安装东西,中间会让你选择是否安装,输入 就行了。

下载过程完成后会自动安装,最终见到  Complete! 就结束了。

返回来还得继续安装PCRE啊,Go:

[plain]  view plain copy print ?
  1. ./configure --prefix=/home/tnuser/pcre/  
  2.   
  3. make  
  4.   
  5. make install  

安装成功,以最终在目标位置生成相应目录为准。


至此,令人eggache的apache准备环境就算搞定了。

五. 继续apache的安装,一定要在参数中带上以上3种环境配置:


[plain]  view plain copy print ?
  1. ./configure --prefix=/home/tnuser/apache/  --with-apr=/home/tnuser/apr/  --with-apr-util=/home/tnuser/apr-util/  --with-pcre=/home/tnuser/pcre/  

大块的log,终于没报错(唯有泪千行啊。。。泪千行。。。)

make

make install

六. 最后测试apache:

cd /home/tnuser/apache/bin

apachectl -k start

如果不能启动,查下端口冲突之类的问题(一般会与系统自带的httpd服务端口冲突)。

启动好后,访问你的apache,看到经典

It works!

关闭时用:apachectl -k stop


七.附录:

http://apache.jz123.cn/install.html   中文版官方编译与安装教程



码完收功!!!


原文地址:http://blog.csdn.net/bob007abc/article/details/8281630

转载于:https://my.oschina.net/u/998304/blog/502084


http://www.niftyadmin.cn/n/1130368.html

相关文章

ASP.NET 应用程序生命周期概览

本文描述应用程序生命周期的摘要信息,列表了重要的生命周期事件并描述如何编写合适的处理代码。在 ASP.NET 中,部分处理步骤只在应用程序初始化并处理请求时才会发生。另外,对来自浏览器的 ASP.NET 请求而提供服务仅是 Web 服务器架构的一小部…

[leetcode]Search in Rotated Sorted Array II @ Python

原题地址:https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/ 题意: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Wri…

父类不能转换成子类

父类不能转换成子类 Exception in thread "main" java.lang.ClassCastException: Person cannot be cast to Boyat Test.main(Test.java:5)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMe…

ansible安装和简单使用

一、安装1、安装第三方epel源centos 5的epelrpm -ivh http://mirrors.sohu.com/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpmcentos 6的epelrpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm由于是6版本所以安装6的epel2、安装ansibl…

Textarea高度随内容自适应地增长,无滚动条

<HTML> <HEAD> <meta http-equiv"Content-Type" content"text/html; charsetUTF-8"> <TITLE>枫芸志 文本框textarea高度自适应增长/伸缩</TITLE> </HEAD> <BODY><textarea id"txtContent" rows&q…

岛田庄司《占星术杀人魔法》读后感

昨天晚上夜谈的时候&#xff0c;聊到了少年包青天里的一个分尸案&#xff0c;今天查了查&#xff0c;叫《隐逸村案》&#xff0c;里面实用6个人的尸体拼出7个人的假象&#xff0c;立即就想到了《占星术杀人案》。其有用这个想法的小说还真不少&#xff0c;包青天里的应该是借鉴…

指定時間點js 倒計時間

指定時間點&#xff1a;<script type "text/javascript"><!--//functionGetRTime(){var EndTime new Date(2006,11,15,12,45); //截止时间:2006年6月10日0时0分var NowTime new Date();var nMS EndTime.getTime() - NowTime.getTime();var nD Math.floor(n…

rabbitmq集群+haproxy 相关 安装与配置和注意事项

安装 erlang , rabbitmq, haproxy erlang 安装 wget http://www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpmyum install erlang-17.4-1.el6.x86_64.rpm 最后输入 erl &#xff0c;进入erlang shell界面就表示安装成功&#xff1a; rabbitmq 安装配置rabbitmq …