apache2.4.9安装

1、下载所需软件包

   根据官网所示,安装apache2.4.9必须先安装apr、apr-util、pcre包

The following requirements exist for building Apache httpd:
APR and APR-Util
Make sure you have APR and APR-Util already installed on your system. If you 
don‘t, or prefer to not use the system-provided versions, download the latest 
versions of both APR and APR-Util from Apache APR, unpack them into ./srclib/apr and 
./srclib/apr-util (be sure the directory names do not have version 
numbers; for example, the APR distribution must be under ./srclib/apr/) and use 
./configure‘s --with-included-apr option. On some 
platforms, you may have to install the corresponding -dev packages 
to allow httpd to build against your installed copy of APR and APR-Util.
Perl-Compatible Regular Expressions Library (PCRE)
This library is required but not longer bundled with httpd. Download the 
source code from http://www.pcre.org, or install a Port or Package. If your 
build system can‘t find the pcre-config script installed by the PCRE build, 
point to it using the --with-pcre parameter. On some platforms, you 
may have to install the corresponding -dev package to allow httpd 
to build against your installed copy of PCRE.

  

2、安装

 解压缩

tar -fvxz apr-1.5.1.tar.gz

tar -fvxz pcre-8.33.tar.gz

tar -fvxz apr-util-1.5.3.tar.gz

tar -fvxz httpd-2.4.9.tar.gz

 编译安装apr

cd apr-1.5.1

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

make && make install 编译安装apr-util cd ../apr-util-1.5.3 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install 编译安装pcre cd ../pcre-8.33 ./configure --prefix=/usr/local/pcre 报错如下:configure: error: You need a C++ compiler for C++ support 安装gcc和c++ yum install -y gcc gcc-c++ make && make install 编译安装apache 安装之前请确保系统之前预装的httpd已被卸载
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event

   

3、错误信息

checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

安装openssl

yum install openssl-devel
yum update openssl
make && make install

  

4、启动测试

 /usr/local/apache/bin/apachectl start

停止服务:/usr/local/apache/bin/apachectl -k stop

  

 5、添加为service

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache //拷贝apache启动脚本
vi /etc/rc.d/init.d/apache    // 这里是编辑apache启动脚本
在开头的#!/bin/sh  下面加上
chkconfig: 2345  85  15
chkconfig --add apache    //添加apache服务
chkconfig --list apache    //列出apache服务
service apache stop    //停止apache服务
netstat -an | grep :80     //查看linux的80端口是否关闭
ps -aux | grep httpd     //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败
service apache start    //启动apache服务

  



linux下安装apache已经成功了

 

Apache默认的访问路径是:/usr/local/apache/htdocs/

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。