#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. Java基础总结--面向对象2

    1.存在相关的多个方法就封装在一个类中,方法没调用到特有数据,需要静态化2.假如一个类所有方法都是静态方法,为了保证不被其他创建对象,可以将该类的构造方法私有化3.文档注释javadoc-按照规定注释 ...

  2. LeetCode 235. Lowest Common Ancestor of a Binary Search Tree (二叉搜索树最近的共同祖先)

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  3. LeetCode 108. Convert Sorted Array to Binary Search Tree (有序数组转化为二叉搜索树)

    Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目 ...

  4. [转]Java - 集合框架完全解析

    数据结构是以某种形式将数据组织在一起的集合,它不仅存储数据,还支持访问和处理数据的操作.Java提供了几个能有效地组织和操作数据的数据结构,这些数据结构通常称为Java集合框架.在平常的学习开发中,灵 ...

  5. 数据模型(LP32 ILP32 LP64 LLP64 ILP64 )

    数据模型(LP32 ILP32 LP64 LLP64 ILP64 ) 32位环境涉及"ILP32"数据模型,是因为C数据类型为32位的int.long.指针.而64位环境使用不同的 ...

  6. 5.volatile的应用

    volatile是轻量级的synchronized,它在多处理器开发中保证了共享变量的"可见性".可见性的意思是当一个线程修改一个共享变量时,另外一个线程能读到这个修改的值.如果v ...

  7. 单元测试 Qunit

    http://api.qunitjs.com/category/assert/    测试方法   选中 "Check for Globals" 会暴露全局对象,看你的代码会不会无 ...

  8. Python基础-注释-变量赋值

    一.注释 # 注释 \n 行分隔符 \ 继续上一行 '''   *** ''' 多行注释 二.基本规则 : 分开代码块(组)   头$尾 缩进块  语句代码块  用缩进深度区分 空行     用于分割 ...

  9. ⑧bootstrap组件 文字图片 下拉菜单 按钮组 使用基础案例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. python基础知识——基于python3.6

    语法糖 # # -*- coding: utf-8 -*- # #------------- # #--------- 语法糖--------------- # #------------------ ...