当前位置:   article > 正文

CentOS7源码包安装apache_apache的centos包

apache的centos包

一、下载apache源码包
1.下载地址:http://httpd.apache.org/download.cgi,下载 httpd-2.4.20.tar.gz
2.上传到服务器目录,/tmp/
解压:tar -zxvf httpd-2.4.20.tar.gz
进入目录:cd httpd-2.4.20
3.编译刚刚解压的源文件,
配置编译参数:
./configure –prefix=/usr/local/apache24/ (配置安装目录 /usr/local/apache24/)
4.正常执行 (说明你的linux安装过apache,或者已经安装了所需的依赖包。)
make
make install
错误信息:
*checking for APR… no
configure: error: APR not found. Please read the documentation.*
解决方案:
二、安装apr
Apache在安装时需要一些准备环境,这里需要安装另外一个东西 APR(Apache Portable Runtime)。

下载地址: http://archive.apache.org/dist/apr/ 同样找最新版本
得到文件:apr-1.5.2.tar.gz
解压:tar -zxvf apr-1.5.2.tar.gz
cd /usr/local/installers/apr-1.5.2    
 ./configure --prefix=/usr/local/apr/   
make 
make install 


完成后在指定地址生成目录和文件
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

三、尝试安装apache
接着装apache,切换到源代码目录设置编译参数: ./configure –prefix=/usr/local/apache24/

还是报上面的错,
        *checking for APR... no
        configure: error: APR not found.  Please read the documentation.*
        解决方案:
这是因为上面自定义了apr的安装目录,所以得把这个信息告诉apache。
./configure --prefix=/usr/local/apache24/  --with-apr=/usr/local/apr/  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

错误信息:
*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.4.tar.gz

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

编译:
    cd /usr/local/installers/apr-util-1.5.4  

     ./configure --prefix=/usr/local/apr-util/   
这次运行会报错:
    checking for APR... no
    configure: error: APR could not be located. Please use the --with-apr option.
看到提示你就懂了,--with-apr:
    ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/  

     make  

     make install   
    在你指定的安装地址生成目录就说明安装成功了
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

四. 继续安装apache
切到apache源代码目录下运行:
./configure –prefix=/usr/local/apache/ –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/*
解决方案:发现还是少环境,下载 PCRE
下载地址: http://jaist.dl.sourceforge.net/project/pcre/pcre/ 找最新版下

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

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

编译:
    cd /usr/local/hunter/installers/pcre-8.37  

    ./configure --prefix=/usr/local/pcre/  
这次错误信息如下:
    *checking for windows.h... no
    configure: error: You need a C++ compiler for C++ support.*
解决方案:
    yum -y install gcc-c++
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

五. 继续apache的安装,一定要在参数中带上以上3种环境配置:
./configure –prefix=/usr/local/apache/ –with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apr-util/ –with-pcre=/usr/local/pcre/

make

make install
  • 1
  • 2
  • 3

最后测试apache
/usr/local/apache24/bin/apachectl start (启动apache)

/usr/local/apache24/bin/apachectl stop          (停止apache)
  • 1
                    <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/production/markdown_views-68a8aad09e.css">
                        </div>
  • 1
  • 2

Apache加入到系统服务里面:
  cp /安装目录下/apache/bin/apachectl /etc/rc.d/init.d/httpd
  修改httpd
  在文件头部加入如下内容:
  ###
  # Comments to support chkconfig on RedHat Linux
  # chkconfig: 2345 90 90
  # description:http server
  ###
  保存
  在打入
  #chkconfig –add httpd
  #chkconfig –level 345 httpd on

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/936504
推荐阅读
相关标签
  

闽ICP备14008679号