码迷,mamicode.com
首页 > Web开发 > 详细

在centos6编译安装httpd-2.4.28

时间:2017-10-21 00:26:55      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:在centos6安装httpd-2.4.28

方法一、

1、安装开发环境包组及相关包:

yum groupinstall “Development Tools”

yum install pcre-devel openssl-devel expat-devel

 

2、下载源代码并解压缩:

rz 导入源代码

tar xvf httpd-2.4.28.tar.bz2   解压缩

tar xvf apr-1.6.2.tar.bz2

tar xvf apr-util-1.6.0.tar.bz2

 

3、安装apr-1.6.2

  ①cd apr-1.6.2

  ②./configure --prefix=/app/apr   指定配置文件路径

  ③make && make install

 

4、安装apr-util-1.6.0

  cd ~/apr-util-1.6.0

  ./configure --prefix=/app/apr-util --with-apr=/app/apr/   编译apr-util时需要调用apr

  make && make install

 

5、编译安装httpd-2.4.28

  cd ~/httpd-2.4.28

  ./configure --prefix=/app/httpd24 \    启用一些特定的功能模块

--enable-so \

--enable-ssl \

--enable-cgi \

--enable-rewrite \

--with-zlib \

--with-pcre \

--with-apr=/app/apr/ \

--with-apr-util=/app/apr-util/ \

--enable-modules=most \

--enable-mpms-shared=all \

--with-mpm=prefork    

  make -j 4 && make install     -j 4表示使用四个处理器同时编译

测试:cd /app/httpd24/bin

    apachectl start 启动服务

   ss -ntl 查看80端口已打开

技术分享

6、为了方便使用,可以配置PATH变量以及服务脚本

  ①添加PATH变量:

   vim /etc/profile.d/path.sh

      PATH=/app/httpd24/bin:$PATH

  执行脚本生效  . /etc/profile.d/path.sh

  ②vim /app/httpd24/conf/httpd.conf   修改如下两行表示以apache身份运行httpd服务

  User apache

  Group apache

  ③配置服务脚本:

  cp /etc/init.d/httpd /etc/init.d/httpd24

   vim  /etc/init.d/httpd24   修改如下四行

        apachectl=/app/httpd24/bin/apachectl

       httpd=${HTTPD-/app/httpd24/bin/httpd}

       pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}

       lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

  ④chkconfig --add httpd24   添加服务脚本

  ⑤service httpd24 restart   重新启动服务

技术分享 

7、测试:

技术分享 


方法二、

    与方法一大致一样,只是编译的时候不一样

1 、安装开发环境包组及相关包:

yum groupinstall "development tools"

yum install openssl-devel pcre-devel expat-devel

 

2 、下载源代码并解压缩:

rz 导入源代码

tar xvf apr-1.6.2.tar.gz

tar xvf apr-util-1.6.0.tar.gz

tar xvf httpd-2.4.28.tar.bz2


3、将apr和apr-util都放到httpd-2.4.28/srclib/下,并且改名

cp -a  apr-1.6.2 httpd-2.4.28/srclib/apr

cp -a apr-util-1.6.0 httpd-2.4.28/srclib/apr-util


4、编译安装

cd httpd-2.4.28

./configure --prefix=/app/httpd24 \

--enable-so \

--enable-ssl \

--enable-cgi \

--enable-rewrite \

--with-zlib \

--with-pcre \

--with-included-apr \

--enable-modules=most \

--enable-mpms-shared=all \

--with-mpm=prefork

make -j 4 && make install

 

5、修改path变量即服务脚本,方便使用

vim /etc/profile.d/httpd24.sh

    PATH=/app/httpd24/bin:$PATH

运行脚本生效 . /etc/profile.d/httpd24.sh

 

6、修改主配置文件,以apache身份运行httpd服务

vim /app/httpd24/conf/httpd.conf

    User apache

    Group apache

 

7、配置服务脚本

cp /etc/init.d/httpd /etc/init.d/httpd24

 

vim /etc/init.d/httpd24

    apachectl=/app/httpd24/bin/apachectl

    httpd=${HTTPD-/app/httpd24/bin/httpd}

    pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}

    lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

 

chkconfig --add httpd24

service httpd24 start    启动服务


8、测试:

技术分享


感谢浏览,如有疑问,欢迎留言

技术分享

在centos6编译安装httpd-2.4.28

标签:在centos6安装httpd-2.4.28

原文地址:http://13150617.blog.51cto.com/13140617/1974733

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!