花蜻宽 发表于 2019-2-15 12:33:21

CentOS6.5安装apache 2.4.37

  1.1 安装Apache2.4
  1.1.1 安装前准备
     卸载系统默认安装的Apache
                       一般来说,操作系统自带或者Apache rpm包方式安装的Apache版本都比较低,且更新不及时,因此我们需要卸载掉安装操作系统时默认被安装上的Apache软件。
  
   查询当前系统中已安装的Apache软件包通过rpm -qa httpd*命令,我们可以查询当前系统中已安装的Apache软件包,具体查询操作如下:

#查询
# rpm -qa httpd*
httpd-tools-2.2.15-69.el6.centos.x86_64
httpd-2.2.15-69.el6.centos.x86_64
#卸载
# rpm -e --nodeps httpd-2.2.15-69.el6.centos.x86_64
# rpm -qa httpd
Rpm 命令参数说明:
-e等同于erase表示移除的意思
---nodeps意思是不考虑依赖
        1.1.2 安装依赖包

                  1)yum安装依赖包

                          提示:必须先用yum把需要的依赖包安装好,再源码编译安装其他的依赖包和Apache软件包,如果先源码编译安装apr,apr-util,再yum安装其他依赖包,最后编译安装Apache时容易安装失败。(经验所得)
#yum -y install gcc gcc-c++ zlib-devel openssl-devel expat-deve pcre pcre-devel                  2) 源码安装apr依赖包

                          下载apr依赖软件包:
# mkdir -p /home/oldboy/tools
# cd /home/oldboy/tools/
# wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.5.tar.gz
--2018-12-06 10:06:22--http://mirrors.hust.edu.cn/apache/apr/apr-1.6.5.tar.gz
Resolving mirrors.hust.edu.cn... 202.114.18.160
Connecting to mirrors.hust.edu.cn|202.114.18.160|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073556 (1.0M)
Saving to: “apr-1.6.5.tar.gz”
100%[=====================================================>] 1,073,556   89.7K/s   in 12s   
2018-12-06 10:06:36 (85.1 KB/s) - “apr-1.6.5.tar.gz” saved
# wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
--2018-12-06 10:06:57--http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
Resolving mirrors.hust.edu.cn... 202.114.18.160
Connecting to mirrors.hust.edu.cn|202.114.18.160|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K)
Saving to: “apr-util-1.6.1.tar.gz”
100%[=====================================================>] 554,301      112K/s   in 4.8s   
2018-12-06 10:07:02 (112 KB/s) - “apr-util-1.6.1.tar.gz” saved
# ll
total 10560
-rw-r--r--. 1 root root 1073556 Sep 14 12:07 apr-1.6.5.tar.gz
-rw-r--r--. 1 root root554301 Oct 232017 apr-util-1.6.1.tar.gz                          安装apr:
# tar zxf apr-1.6.5.tar.gz
# tar zxf apr-util-1.6.1.tar.gz
# cd apr-1.6.5
# mkdir /usr/local/apr-1.6.5
# ./configure --prefix=/usr/local/apr-1.6.5
…………省略内容…………
# make && make install
…………省略内容…………
# ls /usr/local/apr-1.6.5/
binbuild-1includelib
# cd ../apr-util-1.6.1
# mkdir /usr/local/apr-util-1.6.1
# ./configure --prefix=/usr/local/apr-util-1.6.1/ --with-apr=/usr/local/apr-1.6.5/
…………省略内容…………
# make && make install
…………省略内容………
# ls /usr/local/apr-util-1.6.1/
binincludelib  1.1.3 安装Apache

  1)下载httpd-2.4.37

# wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.37.tar.gz
--2018-12-06 10:02:03--http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.37.tar.gz
Resolving mirrors.hust.edu.cn... 202.114.18.160
Connecting to mirrors.hust.edu.cn|202.114.18.160|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9177278 (8.8M)
Saving to: “httpd-2.4.37.tar.gz”
100%[=====================================================>] 9,177,278    221K/s   in 67s   
2018-12-06 10:03:12 (133 KB/s) - “httpd-2.4.37.tar.gz” saved   2)编译安装

# ./configure--prefix=/opt/httpd-2.4.37--enable-so--enable-ssl--enable-cgi --enable-rewrite--with-zlib--with-pcre--with-apr=/usr/local/apr-1.6.5/--with-apr-util=/usr/local/apr-util-1.6.1/--enable-modules=most--enable-mpms-shared=all--with-mpm-prefork
…………省略部分内容…………
    Server Version: 2.4.37
    Install prefix: /opt/httpd-2.4.37
    C compiler:   gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread
    CPPFLAGS:      -DLINUX -D_REENTRANT -D_GNU_SOURCE
    LDFLAGS:         
    LIBS:            
    C preprocessor: gcc -E
# make && make install
…………省略部分内容…………
mkdir /opt/httpd-2.4.37/manual
make: Leaving directory `/home/oldboy/tools/httpd-2.4.37'
# ls /opt/httpd-2.4.37/
binbuildcgi-binconferrorhtdocsiconsincludelogsmanmanualmodules
# ln -s /opt/httpd-2.4.37/ /opt/httpd
# ll -d /opt/httpd
lrwxrwxrwx. 1 root root 18 Dec6 12:04 /opt/httpd -> /opt/httpd-2.4.37/  1.1.4 启动Apache服务

  1)检查语法

# /opt/httpd/bin/apachectl -t
AH00557: httpd: apr_sockaddr_info_get() failed for apache
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK                  2)启动Apache服务

# /opt/httpd/bin/apachectl start
AH00557: httpd: apr_sockaddr_info_get() failed for apache
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message                  3)检查httpd端口

# lsof -i :80
COMMAND    PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   108776   root    4uIPv6 157608      0t0TCP *:http (LISTEN)
httpd   108777 daemon    4uIPv6 157608      0t0TCP *:http (LISTEN)
httpd   108778 daemon    4uIPv6 157608      0t0TCP *:http (LISTEN)
httpd   108779 daemon    4uIPv6 157608      0t0TCP *:http (LISTEN)
# ps -ef|grep httpd
root   108776      10 12:07 ?      00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
daemon   108777 1087760 12:07 ?      00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
daemon   108778 1087760 12:07 ?      00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
daemon   108779 1087760 12:07 ?      00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
root   108863378860 12:08 pts/0    00:00:00 grep httpd  4)Windows访问Apache服务

  查看IP地址
# ifconfig eth0
eth0      Link encap:EthernetHWaddr 00:0C:29:A9:47:CC
          inet addr:10.90.3.130Bcast:10.90.3.255Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea9:47cc/64 Scope:Link
          UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
          RX packets:2792510 errors:0 dropped:0 overruns:0 frame:0
          TX packets:73729 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:481330391 (459.0 MiB)TX bytes:8763678 (8.3 MiB)http://s1.运维网.com/images/20190104/1546592659802787.png

  安装Apache2.4到此结束!



页: [1]
查看完整版本: CentOS6.5安装apache 2.4.37