系统环境:
Nginx Web:hostname:apache #IP:192.168.199.103/24 Centos 6.4 2.6.32-358.el6.x86_64
预装配置:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
#!/bin/bash # Author:Byrd # Version:1.0 # Site:note.t4x.org # Contact:root#t4x.org #This script for Apache PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH LANG="en_US.UTF-8" # Check if user is root if [ $UID != "0" ]; then echo "Error: You must be root to run this script, please use root to install lnmp" exit 1 fi clear echo "=========================================================================" echo "THIS SCRIPT WILL INSTALL APACHE WEBSERVER BY:BYRD AT:2014-04-30" echo "=========================================================================" RETVAL=0 PcreVen=pcre-8.33 ArpVersion=apr-1.5.1 HttpdVen=httpd-2.4.10 ArpUtilVersion=apr-util-1.5.3 ApacheDir=/byrd/server InstallTools=/byrd/tools Httpd=http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.10.tar.gz ApacheArpUrl=http://archive.apache.org/dist/apr/apr-1.5.1.tar.gz ApacheArpUtil=http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz Pcre=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz [ ! -d $InstallTools ] && mkdir -p $InstallTools [ ! -d $ApacheDir ] && mkdir $ApacheDir yum install vim wget zlib-devel gcc gcc-c++ -y cd $InstallTools if [ ! -f $ArpVersion.tar.gz ];then wget $ApacheArpUrl tar -zxf $ArpVersion.tar.gz cd $ArpVersion ./configure make && make install RETVAL1=$? elif [ -f $ArpVersion.tar.gz ];then tar -zxf $ArpVersion.tar.gz cd $ArpVersion ./configure make && make install RETVAL1=$? else exit 1 fi if [ `echo $RETVAL1` -eq $RETVAL ];then echo "$ArpVersion Install Successful" else exit $RETVAL1 fi cd $InstallTools if [ ! -f $ArpUtilVersion.tar.gz ];then wget $ApacheArpUtil tar -zxf $ArpUtilVersion.tar.gz cd $ArpUtilVersion ./configure --with-apr=/usr/local/apr make && make install RETVAL2=$? elif [ -f $ArpUtilVersion.tar.gz ];then tar -zxf $ArpUtilVersion.tar.gz cd $ArpUtilVersion ./configure --with-apr=/usr/local/apr make && make install RETVAL2=$? else exit 1 fi if [ `echo $RETVAL2` -eq $RETVAL ];then echo "$ArpUtilVersion Install Successful" else exit $RETVAL2 fi cd $InstallTools if [ ! -f $PcreVen.tar.gz ];then wget $Pcre tar -zxf $PcreVen.tar.gz cd $PcreVen ./configure make && make install RETVAL3=$? else tar -zxf $PcreVen.tar.gz cd $PcreVen ./configure make && make install RETVAL3=$? fi if [ `echo $RETVAL3` -eq $RETVAL ];then echo "$PcreVen Install Successful" else exit $RETVAL3 fi cd $InstallTools if [ ! -f $HttpdVen.tar.gz ];then wget $Httpd || exit 1 tar -zxf $HttpdVen.tar.gz cd $HttpdVen ./configure --prefix=$ApacheDir/$HttpdVen --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite make && make install RETVAL4=$? else tar -zxf $HttpdVen.tar.gz cd $HttpdVen ./configure --prefix=$ApacheDir/$HttpdVen --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite make && make install RETVAL4=$? fi if [ `echo $RETVAL4` -eq $RETVAL ];then echo "$HttpdVen Install Successful" else exit $RETVAL4 fi ln -s $ApacheDir/$HttpdVen /usr/local/apache /usr/local/apache/bin/apachectl -k start /bin/netstat -tunlp | /bin/grep 80 if [ -s /sbin/iptables ]; then /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT /sbin/iptables-save fi if [ `/bin/netstat -tunlp | /bin/grep 80 |wc -l` -eq 1 ]; then echo "Aapche Start Successful" else echo "Error." fi |
安装过程:
0 1 2 3 4 5 6 7 8 9 10 11 12 |
cd /byrd/tools #wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.9.tar.gz && tar -zxf httpd-2.4.9.tar.gz cd httpd-2.4.9 ./configure --prefix=/byrd/server/httpd-2.4.9 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite && make && make install ln -s /byrd/server/httpd-2.4.9 /usr/local/apache /byrd/server/httpd-2.4.9/bin/httpd /bin/netstat -tunlp | /bin/grep 80 if [ -s /sbin/iptables ]; then /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT /sbin/iptables-save fi |
申明:本文由BYRD原创(基于Centos6.4 X64、httpd-2.4.9),未经许可禁止转载!
官方参数:http://httpd.apache.org/docs/2.4/ SourceByrd's Weblog-https://note.t4x.org/environment/config-apache-webserver/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Trackbacks