#apache编译安装
#httpd 2.2 , httpd 2.4

#!/bin/sh
#apache编译安装
#httpd 2.2 , httpd 2.4
#centos #rpm -e httpd*
Ve=2.2
[ $ = 2.4 ] && Ve=2.4 || Ve=2.2 #设置安装版本2.2或2. #目录
Ddir=/it/tools #定义下载目录
Sdir=/www/server #定义安装目录
Adir=$Sdir/apache$Ve
[ ! -d $Ddir ] && mkdir -p $Ddir
mkdir -p $Adir echo '#安装需要的库'
yum install make gcc gcc-c++ pcre pcre-devel zlib* -y
yum install expat-devel -y #安装apr-util需要
#yum install apr apr-util -y
yum install wget lrzsz -y
yum install openssl openssl-devel -y # echo '#添加用户'
# useradd apache -s /sbin/nologin -M
# id apache echo "#下载"
cd $Ddir
wget http://mirrors.aliyun.com/apache/apr/apr-1.6.2.tar.gz
wget http://mirrors.aliyun.com/apache/apr/apr-util-1.6.0.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
[ $Ve = 2.4 ] && {
wget http://mirrors.aliyun.com/apache/httpd/httpd-2.4.27.tar.gz ;
}|| {
wget http://mirrors.aliyun.com/apache/httpd/httpd-2.2.34.tar.gz ;
} echo "解压"
tar -xf apr-.*.tar.gz
tar -xf apr-util-.*.tar.gz
tar -xf pcre-.*.tar.gz
tar -xf httpd-$Ve.*.tar.gz
[ $? = ] || { echo "解压出现问题 !";exit; } echo "#安装"
mkdir -p $Sdir/http/{apr,apr-util,pcre}
cd $Ddir
#apr
cd apr-.*
./configure --prefix=$Sdir/http/apr/
[ $? = ] || { echo "编译出现问题 !";exit; }
make && make install
cd ..
#apr-util
cd apr-util-.*
./configure --prefix=$Sdir/http/apr-util/ --with-apr=$Sdir/http/apr/
[ $? = ] || { echo "编译出现问题 !";exit; }
make && make install
cd ..
#pcre
cd pcre-.*
./configure --prefix=$Sdir/http/pcre/
[ $? = ] || { echo "编译出现问题 !";exit; }
make && make install
cd .. #httpd
cd $Ddir/httpd-$Ve.*
#./configure --help
./configure \
--prefix=$Adir \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite \
--with-apr=$Sdir/http/apr/ \
--with-apr-util=$Sdir/http/apr-util/ \
--with-pcre=$Sdir/http/pcre/ \
ap_cv_void_ptr_lt_long=no
#
[ $? = ] || { echo "编译出现问题 !";exit; }
echo 编译安装
make -j4 && make install
echo '#编译模块查看'
$Adir/bin/apachectl -l pkill `netstat -antp|grep |awk -F '/' '{ print $2}'` &>/dev/null #关闭80端口进程
echo "ServerName localhost:80">>$Adir/conf/httpd.conf
echo '#启动apache'
$Adir/bin/apachectl start
echo '#查看'
netstat -antp|grep httpd
ps -ef|grep http|grep -v "grep"
echo "$Adir/bin/apachectl { start|restart|stop }" # 加入系统服务,开机启动
sed -i -e '2 i #chkconfig: 2345 70 60 \n#description: apache' $Adir/bin/apachectl
# ln -s $Adir/bin/apachectl /etc/init.d/httpd
# echo "$Adir/bin/apachectl start">>/etc/rc.local
# chkconfig --add httpd
# chkconfig httpd on
# chkconfig --list httpd # # #添加环境变量
# echo "export PATH=$Adir/bin:$PATH">>/etc/profile.d/httpd.sh
# . /etc/profile.d/httpd.sh # #添加库文件至系统
# echo "$Adir/include/">>/etc/ld.so.conf.d/httpd.conf
# ldconfig # #man文档添加至系统
# man -M $Adir/man httpd
# echo "MANPATH $Adir/man">>/etc/man.config # #隐藏头文件版本
# echo "#隐藏头文件版本
# ServerTokens ProductOnly
# ServerSignature Off
# ">>$Adir/conf/httpd.conf #php 测试
echo '<?php phpinfo(); ?>'>$Adir/htdocs/test.php
# other
#--sysconfdir=/etc/httpd \ #Apache配置php
#php编译时,需要有参数--with-apxs2=/apache安装目录/bin/apxs \
#php编译完成后,apache配置文件里会自动添加php模块LoadModule php5_module module/libphp5.so
#echo "Addtype application/x-httpd-php .php .phtml">>$Adir/conf/httpd.conf #开启php支持 #另一种方式,使用fcgi接口方式,传递php给独立php进程解析,配置略

apache编译安装 httpd 2.2 httpd 2.4的更多相关文章

  1. LANMP系列教程之Apache编译安装CentOS7环境

      1.准备好源码包并配置好yum源,需要的源码包包括:httpd-2.4.18.apr-1.5.2.tar.gz.apr-util-1.5.4.tar.gz 2.准备用户 groupadd -r a ...

  2. Apache编译安装

    1.准备好源码包并配置好yum源,需要的源码包包括:httpd-2.4.18.apr-1.5.2.tar.gz.apr-util-1.5.4.tar.gz 2.准备用户 groupadd -r apa ...

  3. apache编译安装参数说明

    apache编译安装参数说明 ./configure //配置源代码树--prefix=/usr/local/apache2 //体系无关文件的顶级安装目录prefix ,也就apache的安装目录. ...

  4. 末学者笔记--apache编译安装及LAMP架构上线

    apache介绍 一.Apache的三种工作模式 Apache一共有3种稳定的MPM模式(多进程处理模块),它们分别是prefork.worker.event.http-2.2版本的httpd默认的m ...

  5. Centos 7 Apache编译安装

    1.安装apache ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so --enable-headers --e ...

  6. Apache编译安装及LAMP架构

    1.apache三种工作模式 1)prefork工作模式 一个进程处理一个用户请求 稳定但是不适合高并发的生产环境 2)worker工作模式 一个进程生成多个线程 合适高并发环境但是需要考虑到线程的安 ...

  7. Apache 编译安装

    # wget http://www.apache.org/dist/httpd/httpd-2.2.9.tar.gz  (此处我是直接用的下载好的包) # tar -zxvf httpd-2.2.9. ...

  8. apache编译安装php后需要注意以下配置

    安装后, 编辑apache配置文件 vi /usr/local/apache2/conf/httpd.conf 可以看到 LoadModule php7_module modules/libphp7. ...

  9. LAMP 1.2 Apache编译安装

    1.下载                                                                                                 ...

随机推荐

  1. IOC杂谈(一)初识IOC

    初衷 发现学习东西不单只是看,用,还有很重要一点就是记录,不然过个几个月再用到相同的知识时,你会发现你已经丢得差不多了,故此开始在博客园记录的同时也与各位同行分享知识. 正题 关于IOC,在刚工作时就 ...

  2. Yii2之行为

    Yii三大特性:属性.事件.行为.前面两篇文章已经分别讲解了属性和事件,本文接着讲讲yii的行为,分析yii行为的实现原理. 在yii中,一个对象绑定了行为之后,就拥有了所绑定行为拥有的所有事件,而且 ...

  3. aapt不是内部命令

    解决方法:在E:\sdk\build-tools\目录下的任意文件夹下查找aapt,复制到E:\sdk\platform-tools,具体盘符是情况而定,如果还不行,尝试配置环境变量!

  4. VUE 源码学习01 源码入口

    VUE[version:2.4.1] Vue项目做了不少,最近在学习设计模式与Vue源码,记录一下自己的脚印!共勉!注:此处源码学习方式为先了解其大模块,从宏观再去到微观学习,以免一开始就研究细节然后 ...

  5. 使用bower init创建bower.json文件

    使用bower init 可以快速创建bower.json文件 bower init 回答一系列问题后就可以了,其中大部分问题可以按enter跳过.

  6. J - Scarily interesting! URAL - 2021

    This year at Monsters University it is decided to arrange Scare Games. At the Games all campus gathe ...

  7. C# join子句

    join 子句可用于将来自不同源序列并且在对象模型中没有直接关系的元素相关联. 唯一的要求是每个源中的元素需要共享某个可以进行比较以判断是否相等的值. 例如,食品经销商可能拥有某种产品的供应商列表以及 ...

  8. 针对数据量较大的表,需要进行跨库复制,采用navcat 实现sqlite数据库跨数据库的数据表迁移 [转载]

    2014年12月13日 14:36 新浪博客 (转自http://www.cnblogs.com/nmj1986/archive/2012/09/17/2688827.html) 需求: 有两个不同的 ...

  9. 如何让只支持IE浏览器的jsp转为可以支持chrome

    如果你的项目只能使用IE浏览器打开,你想让其支持chrome的话,可以试一下下面的代码哦: function showLayerDialog(url,paramFuction){ top.layer. ...

  10. JavaScript系列----AJAX机制详解以及跨域通信

    1.Ajax 1.1.Ajax简介 Ajax简介这一部分我们主要是谈一下ajax的起源,ajax是什么?因为这些是跟技术无关的.所以,大多细节都是一笔带过. Ajax的起源? Ajax一词源于2005 ...