【问题标题】:Apache httpd setup and installationApache httpd 设置和安装
【发布时间】:2012-03-15 06:19:54
【问题描述】:

这是我第一次尝试以普通用户(非 root)的身份在本地安装 Apache HTTP 服务器。

我已经下载了 Apache 2.4.1 版本的 Apache HTTP 服务器 [http://httpd.apache.org/download.cgi]。但是,当我尝试在我的盒子中本地构建和安装时,出现以下错误:

httpd/httpd-2.4.1 1059> ./configure
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

Configuring Apache Portable Runtime library ...

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

我不确定它在寻找什么依赖 - 我的意思是下载包不包含它?我需要做什么来构建/部署 Apache HTTP 服务器?

提前致谢。

【问题讨论】:

  • @JimGarrison,那为什么不关闭/移动呢?

标签: apache apr


【解决方案1】:

当它告诉您 Please read documentation 时,这意味着您应该去阅读 Apache 文档 (http://httpd.apache.org/docs/2.4/install.html),它会告诉您

从Apache APR 下载 APR 和 APR-Util 的最新版本, 将它们解压到 ./srclib/apr 和 ./srclib/apr-util 中(确保 域名没有版本号;例如,APR 分发必须在 ./srclib/apr/)

然后做

./configure --with-included-apr

【讨论】:

  • ` httpd/httpd-2.4.1 1062> ./configure --with-included-apr 检查所选布局... Apache 检查工作 mkdir -p... 是检查 grep处理长行和 -e... /bin/grep unknown-linux-gnu 检查目标系统类型... x86_64-unknown-linux-gnu 配置 Apache 可移植运行库 ... 配置:错误:已请求捆绑 APR 但未找到在./srclib/。下载并解压对应的apr和apr-util包到./srclib/。 ` 哪个是要下载的正确站点,我应该在哪里安装
  • 甜蜜的成功.. 需要更改 Makefile 中的行:#PROGRAM_LDADD = buildmark.o $(HTTPD_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(PCRE_LIBS) $(EXTRA_LIBS) $(AP_LIBS) $(LIBS) - ---> PROGRAM_LDADD = buildmark.o $(HTTPD_LDFLAGS) $(PROGRAM_DEPENDENCIES) $HOME/lib/usr/local/lib/libpcre.a $(EXTRA_LIBS) $(AP_LIBS) $(LIBS)
  • 注意./srclib 表示srclib 目录在您的httpd-xxx 目录中
  • 他们为什么不直接为您包含这些内容?这似乎是在浪费时间
  • 预先将 apr 和 apr-util 作为独立的软件包安装有什么好处,而不是仅仅在 apache 中包含它们的源代码?
【解决方案2】:

对于 Ubuntu 11.10,此选项似乎运行良好:

 # APR

wget http://mirrors.axint.net/apache//apr/apr-1.4.6.tar.gz

tar -xvzf apr-1.4.6.tar.gz

cd apr-1.4.6/

./configure

make

make install

cd ..

# APR Utils

wget http://mirrors.axint.net/apache//apr/apr-util-1.4.1.tar.gz

tar -xvzf apr-util-1.4.1.tar.gz

cd apr-util-1.4.1

./configure --with-apr=/usr/local/apr

make

make install

cd ..

# Apache

wget http://apache.petsads.us//httpd/httpd-2.4.1.tar.gz

tar -xvzf httpd-2.4.1.tar.gz

cd httpd-2.4.1

./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-ssl --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so --with-apr=/usr/local/apr/

make

make install

cd ..

您可以在下面找到有关它的更多信息

来源:VaporCreations.com

【讨论】:

  • 除非您是 root 用户,否则您需要在“make install”调用中添加“sudo”前缀
  • 谢谢。我在 ./configure 中遗漏了一些参数
  • make install之后如何在Red Hat Enterprise Linux Server release 7.4 (Maipo)上启动httpd服务?
【解决方案3】:

如果你有 Debian/Ubuntu,你可以:

apt-get install libapr1-dev libaprutil1-dev

然后./configure

完成

【讨论】:

  • 这对 ubuntu 用户有帮助
【解决方案4】:

以下是我在非 root 用户上安装 apache-httpd 的步骤:

  1. 下载并解压 apache-httpd-2.4.2(但在 ./configuring 之前, 制作和安装它,请按照以下步骤操作:)
  2. 下载并解压 APR & APR-UTIL 到 "./srclib/apr" & “./srclib/apr-util”文件夹。这需要 ./config --with-apr=./apache/httpd-2.4.2/srclib/apr(和)--with-included-apr(选项)。
  3. 下载、提取、./configure (with) --prefix=localURL、make and 将 PCRE 安装到“./pcre”文件夹中。这需要 ./config --with-pcre=/home/username/apache/pcre(选项)。
  4. 通过输入以下命令配置 apache-httpd(我喜欢 启用以下命令中编写的某些选项): ./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so - -with-apr=/home/username/apache/httpd-2.4.2/srclib/apr --prefix=/home/username/apache/httpd-2.4.2/ --with-included-apr --with-pcre =/home/用户名/apache/pcre 注意:配置 apache-httpd 时,仅当安装了 OpenSSL 时才使用选项“--enable-ssl”,否则不要启用它。
  5. 现在在命令行中,输入“make”和“make install”命令。
  6. 打开并配置“httpd.conf”文件,例如: "vi /home/eddie_kumar/apache/httpd-2.4.2/conf/httpd.conf"

重要提示:不要忘记将默认端口从 80 更改为其他值,例如8080,这对于非root用户尤其重要 用户。 (如何?打开 httpd.conf -> 搜索“Listen 80” -> 更改它 到“听 8080”。

就是这样,现在打开浏览器输入“localhost:8080”,应该会显示“It works!”。

【讨论】:

  • 如果您是 debian 用户,只需执行“apt-get install libpcre3-dev”
  • 在make install之后如何在Red Hat Enterprise Linux Server release 7.4 (Maipo)上启动httpd服务?
【解决方案5】:

如果您使用 Fedora,您可以使用 yum 安装 APR、APR-Util 和 PCRE。您还需要下载 apr-devel、apr-util-devel 和 pcre-devel。

话虽如此,您只需在终端上运行以下命令,就不会再出现“configure: error: APR not found.. ..APR-Util and PCRE”错误。

yum -y install arp apr-devel apr-util apr-util-devel pcre pcre-devel 

我正在使用 Fedora 17 并计划使用 shell 脚本来设置 apache 2.4.3。所以 yum 工作起来相当流畅,而不是手动下载 apr、apr-util 和 pcre。

【讨论】:

  • 太棒了!不清楚您是否需要 -devel 版本。如果您是 fedora 或 redhat,或者是 redhat 的 amazon ec2 AWS 实例,这是最佳答案。
【解决方案6】:

1、你需要APR(apache便携式运行时),它是apache web server的核心组件

2、如果要make install,可能需要root账号

3,即使没有,apache也无法在没有root帐户的情况下开始监听非特权端口(低于1024)

4,获得 root 权限或让具有 root 权限的人从官方 repo 安装 apache(我不知道您运行的是哪个发行版),例如使用 yum、apt-get 等...

【讨论】:

    【解决方案7】:

    Apr 或 pcre 相关错误需要下载源代码,并且需要让 Apache HTTPD“配置”过程了解文件系统上的这些源代码位置。例如:如果您在 ./srclib(相对于 apache httpd)下载了 APR 的源代码,那么您将使用
    --with-included-apr
    作为配置选项。

    另一方面,如果您不想构建而是安装 APR / APR-UTIL,那么您需要在 CentOS / RedHat 上进行以下操作:
    yum install apr-util-devel apr-devel
    然而,yum 提供的 APR 版本可能与此版本的 Apache httpd 所期望的不匹配。在这种情况下,您可以下载 APR 和 APR-UTIL 并使用 --with-included-apr 选项。

    您也可以使用相同的“配置、制作、制作安装”过程构建 PCRE,然后从您停止构建 Apache httpd 的地方继续。
    或者你可以安装pcre: 百胜安装pcre-devel

    如果在构建 PCRE 时:您看到“编译:无法识别的选项”,那么您可能还需要其他依赖项:请查看详细信息:
    http://khanna111.com/wordPressBlog/2012/09/11/94087-2/
    它还涵盖了“mod_deflate”和“zlib”。

    【讨论】:

      【解决方案8】:

      基本步骤

      tar -xvf httpd-2.4.1-customized.tar -C ../
      #Balancer folder will be created
      tar -xvzf openssl-1.0.1.tar.gz  -C /balancer/
      cd ->/balancer/openssl-1.0.1
      ./config --prefix=/usr/local/ssl/ shared zlib-dynamic enable-camellia
      make depend
      make
      make install
      tar -xvzf pcre-8.30.tar.gz -C ../balancer/
      
      /balancer/pcre-8.30
      ./configure  --prefix=/usr/local/pcre/
      make
      make install
      

      删除pcre和openssl

      【讨论】:

        【解决方案9】:

        在 Ubuntu 机器上安装和编译 Apache 服务器

        第 1 步:安装 Java JDK

        sudo apt install openjdk-11-jdk
        
        sudo gedit /etc/environment
        
        JAVA_HOME="/usr/lib/jvm/openjdk-11"
        
        source /etc/environment
        
        echo $JAVA_HOME
        

        验证java版本

        javac --version
        

        ****安装其他需要的包:**

          sudo apt-get install apache2-dev -y 
        
        sudo apt-get install libpcre3 libpcre3-dev
        

        第 2 步:安装 Apache HTTP 服务器

        #1 对于 ubuntu,安装开发工具,包括 C 编译器:

        sudo apt-get install build-essential checkinstall
        

        #2 下载并解压所需文件

        假设所有文件都已下载到~/Downloads目录

        从 Apache 下载页面 (https://httpd.apache.org/download.cgi) 下载 Apache HTTP Server httpd-2.4.41.tar.gz

        以及以下编译 apache HTTP 服务器所需的库:

        ****阅读需求部分(http://httpd.apache.org/docs/2.4/install.html)***

        #3 解压 tar 文件

        • tar -xvf httpd-2.4.41.tar.gz
        • tar -xvf apr-1.7.0.tar.gz
        • tar -xvf apr-util-1.6.1.tar.gz
        • tar -xvf pcre2-10.34.tar.gz

        解压后你应该在 ~/Downloads 中看到以下目录列表

        • httpd-2.4.41
        • apr-1.7.0
        • apr-util-1.6.1
        • pcre2-10.34

        #4 为 apache HTTP Server 创建目录

        *确保授予此目录的所有权限,以便在编译文件时可以读取/写入

         sudo mkdir /home{your username here}/apache
        

        授予 apache 目录的所有权限:

        sudo chmod -R 777 /home{your username here}/apache
        

        #5 将arp和arp-util目录复制到~/Downloads/httpd-2.4.41/srclib/

        cd ~/Downloads
        
        mv  apr-util-1.6.1  ~/Downloads/httpd-2.4.41/srclib/apr-util
        
         mv  apr-1.7.0  ~/Downloads/httpd-2.4.41/srclib/apr
        

        #6 配置编译源。 --prefix 选项可用于将 Web 服务器安装在可以写入文件的位置。

        cd ~/Downloads/httpd-2.4.41/
        
        
        ./configure  --prefix=/home/{username here}/apache --with-pcre=~/Downloads/pcre2-10.34
        

        注意: 如果你在运行上面的命令时遇到了一些问题,你也可以试试

        在 /usr/local/pcre 中安装 pcre,使用

        ./configure --prefix=/usr/local/pcre 制作 须藤制作安装

        命令,然后运行以下命令:

           cd ~/Downloads/httpd-2.4.41/
        

        ./configure --prefix=/home/{username here}/apache --with-pcre=/usr/local/pcre

        制作

          sudo make install
        

        如果您仍然遇到一些问题,请确保 ~/apache 及其嵌套目录具有读/写权限。如果没有再次运行**sudo chmod -R 777 /home{your username here}/apache** 命令。

        #7 编译 Apache HTTP 服务器。

        cd ~/Downloads/httpd-2.2.25
        
        sudo make
        

        #8 安装 Apache HTTP 服务器。

        cd ~/Downloads/httpd-2.2.25
        
        sudo make install
        

        可选 #9 准备主机文件

        sudo gedit /etc/hosts
        

        27.0.0.1 本地主机 www.example.com

        sudo gedit /home/{your username here}/apache/conf/httpd.conf
        

        并复制:

        Listen 8000
        
        ServerName www.example.com:8000
        

        #10 测试安装以确保 Apache HTTP Server 正常工作。

        /home/{your username here}//apache/bin/apachectl -k start
        

        【讨论】:

        • #./apachectl -k start httpd:/usr/local/apache/conf/httpd.conf 第 66 行的语法错误:无法将模块/mod_authn_file.so 加载到服务器:/usr/local /apache/modules/mod_authn_file.so:无法打开共享对象文件:没有这样的文件或目录
        猜你喜欢
        • 2011-07-12
        • 2012-06-23
        • 2014-06-21
        • 2015-05-30
        • 2019-07-13
        • 2014-07-16
        • 1970-01-01
        • 2018-10-04
        • 2015-09-17
        相关资源
        最近更新 更多