帮助中心 >
编译安装 Apache

[root@ebadu tmp]# wget http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.24.tar.gz
[root@ebadu tmp]# tar xzf httpd-2.2.24.tar.gz
[root@ebadu tmp]# cd httpd-2.2.24
先安装需要的依赖包 
yum install -y gcc gcc-c++ make sudo autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel patch libmcrypt-devel libmhash-devel ncurses-devel bzip2 libcap-devel ntp sysklogd
运行安装php

禁用SeLinux

 

selinux可能会致使编译安装失败,我们先禁用它。
1  sed-i 's/SELINUX=enforcing/SELINUX
=disabled/g' /etc/selinux/config //永久禁用,需要重启生效
2  setenforce 0 //临时禁用,不需要重启
yum安装必要工具
 

1、安装编译工具gcc gcc-c++make automake autoconf kernel-devel
2、安装PHP所需依赖,如libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel等

yum -y install gcc gcc-c++  make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel  pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils   readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel
安装apache

  1. cd /tmp/httpd-2.2.24
  2. ./configure --prefix=/usr/local/apache --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared  --enable-headers=shared --enable-rewrite=shared --enable-static-support
  3. make
  4. make install


编译参数解释:
–prefix=/usr/local/apache:指定安装目录
–with-included-apr:在编译时强制使用当前源代码中绑定的APR版本
–enable-so:允许运行时加载DSO模块
–enable-deflate=shared:将deflate模块编译为DSO
–enable-expires=shared:将expires模块编译为DSO
–enable-headers=shared:将headers模块编译为DSO
–enable-rewrite=shared:将rewrite模块编译为DSO
–enable-static-support:使用静态连接(默认为动态连接)编译所有二进制支持程序
更详细的编译参数解释:http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html\


##到这一步,会卡,配置好的会卡一会,不好的会卡10几分钟,等待即可。
  • cp build/rpm/httpd.init /etc/init.d/httpd //使用init脚本管理httpd
  • chmod 755 /etc/init.d/httpd //增加执行权限
  • chkconfig --add httpd  //添加httpd到服务项
  • chkconfig  httpd on   //设置开机启动
  • ln -fs /usr/local/apache/ /etc/httpd
  • ln -fs /usr/local/apache/bin/httpd /usr/sbin/httpd
  • ln -fs /usr/local/apache/bin/apachectl /usr/sbin/apachectl
  • ln -fs /usr/local/apache/logs /var/log/httpd //设置软链接以适应init脚本