apache httpd 2.4编译安装

apache编译安装

#一.安装环境

  • 系统版本
[root@localhost ~]# head -n 1 /etc/issue
CentOS release 6.5 (Final)
  • 软件版本 apr-1.5.2.tar.gz apr-util-1.5.4.tar.gz httpd-2.4.20.tar.gz
  • 安装编译代码需要环境
yum -y groupinstall "Development Tools"
编译安装httpd时,可以避免遇到openssl版本过低的问题和缺少pcre库支持的问题:
yum install openssl-devel
yum update openssl
yum install -y pcre-devel

#二.安装apr和apr-util

  • 编译安装apr
#tar xf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure--prefix=/usr/local/apr
# make && make install
  • 编译安装apr-util
# tar xf apr-util-1.5.4.tar.gz 
# cd apr-util-1.5.4
# ./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr
# make && make install

#三.编译httpd参数解释 --prefix:指定安装路径 --sysconfdir:指定生成的配置文件路径 --enable-so:DSO兼容,DSO=Dynamic Shared Object,动态共享对象,可实现模块动态生效 --enable-ssl:支持SSL/TLS --enable-cgi:#支持CGI脚本(默认对非线程的MPM模式开启) --enable-rewrite:启用Rewrite功能,URL重写 --with-zlib:使用指定的zlib库,不指定路径会自动寻找 --with-pcre:使用指定的PCRE库,不指定路径会自动寻找 需已安装pcre-devel --with-apr:指定apr安装路径 --with-apr-util:指定apr-util安装路径 --enable-mpms-shared:支持动态加载的MPM模块,可选参数:all --with-mpm:设置默认启用的MPM模式,{prefork|worker|event} --enable-modules:支持动态启用的模块,可选参数:all,most,few,reallyall 编译之前可使用./configure --help查看各项参数 httpd的MPM(多处理模块)的相关介绍

#四.编译安装httpd

# tar xvf httpd-2.4.20.tar.gz 
# cd httpd-2.4.20
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event --enable-cgi --enable-cgid
# make && make install
# cd /usr/local/apache
# bin/apachectl start
如过遇到httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message这个提示,可以进行如下操作:
# vim /etc/httpd/httpd.conf 修改  ServerName  localhost:80

#五.将httpd的安装目录的bin加入PATH:

在/etc/profile.d目录下面创建httpd.sh,添加
PATH=$PATH:/usr/local/apache/bin

#六.输出apache的man手册至man命令的查找路径: 编辑/etc/man.config,添加如下行即可:

MANPATH  /usr/local/apache/man

#七.输出apache的头文件至系统头文件路径/usr/include: 这可以通过简单的创建链接实现:

# ln -sv /usr/local/apache/include  /usr/include/apache

#八.将/usr/local/logs下的httpd.pid文件移到/var/run下

vim /etc/httpd/httpd.conf 加入 PidFile  "/var/run/httpd.pid"
而后重新启动httpd:
# cd /usr/local/apache
# bin/apachectl stop
# bin/apachectl start

apache编译到此结束。动手做一做吧!

转载于:https://my.oschina.net/u/2366409/blog/689506

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值