1.1 安装Apache2.4
1.1.1 安装前准备
卸载系统默认安装的 Apache
一般来说,操作系统自带或者 Apache rpm包方式安装的 Apache版本都比较低,且更新不及时,因此我们需要卸载掉安装操作系统时默认被安装上的 Apache软件。
查询当前系统中已安装的 Apache软件包 通过 rpm -qa httpd*命令,我们可以查询当前系统中已安装的 Apache软件包,具体查询操作如下:
#查询
[root@localhost /]# rpm -qa httpd*
httpd-tools-2.2.15-69.el6.centos.x86_64
httpd-2.2.15-69.el6.centos.x86_64
#卸载
[root@localhost /]# rpm -e --nodeps httpd-2.2.15-69.el6.centos.x86_64
[root@localhost /]# rpm -qa httpd
[root@localhost /]Rpm 命令参数说明:
-e 等同于 erase 表示移除的意思
---nodeps 意思是不考虑依赖
1.1.2 安装依赖包
1)yum安装依赖包
提示:必须先用yum把需要的依赖包安装好,再源码编译安装其他的依赖包和Apache软件包 ,如果先源码编译安装apr,apr-util,再yum安装其他依赖包,最后编译安装Apache时容易安装失败。(经验所得)
[root@apache httpd-2.4.37]# yum -y install gcc gcc-c++ zlib-devel openssl-devel expat-deve pcre pcre-devel 2) 源码安装apr依赖包
下载apr依赖软件包:
[root@apache /]# mkdir -p /home/oldboy/tools
[root@apache /]# cd /home/oldboy/tools/
[root@apache 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) [application/octet-stream]
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 [1073556/1073556]
[root@apache tools]# 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) [application/octet-stream]
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 [554301/554301]
[root@apache tools]# 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 root 554301 Oct 23 2017 apr-util-1.6.1.tar.gz 安装apr :
[root@apache tools]# tar zxf apr-1.6.5.tar.gz
[root@apache tools]# tar zxf apr-util-1.6.1.tar.gz
[root@apache tools]# cd apr-1.6.5
[root@apache apr-1.6.5]# mkdir /usr/local/apr-1.6.5
[root@apache apr-1.6.5]# ./configure --prefix=/usr/local/apr-1.6.5
…………省略内容…………
[root@apache apr-1.6.5]# make && make install
…………省略内容…………
[root@apache apr-1.6.5]# ls /usr/local/apr-1.6.5/
bin build-1 include lib
[root@apache apr-1.6.5]# cd ../apr-util-1.6.1
[root@apache apr-util-1.6.1]# mkdir /usr/local/apr-util-1.6.1
[root@apache apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util-1.6.1/ --with-apr=/usr/local/apr-1.6.5/
…………省略内容…………
[root@apache apr-util-1.6.1]# make && make install
…………省略内容………
[root@apache apr-util-1.6.1]# ls /usr/local/apr-util-1.6.1/
bin include lib 1.1.3 安装Apache
1)下载httpd-2.4.37
[root@apache tools]# 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) [application/octet-stream]
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 [9177278/9177278] 2)编译安装
[root@apache httpd-2.4.37]# ./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
[root@apache httpd-2.4.37]# make && make install
…………省略部分内容…………
mkdir /opt/httpd-2.4.37/manual
make[1]: Leaving directory `/home/oldboy/tools/httpd-2.4.37'
[root@apache httpd-2.4.37]# ls /opt/httpd-2.4.37/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@apache httpd-2.4.37]# ln -s /opt/httpd-2.4.37/ /opt/httpd
[root@apache httpd-2.4.37]# ll -d /opt/httpd
lrwxrwxrwx. 1 root root 18 Dec 6 12:04 /opt/httpd -> /opt/httpd-2.4.37/ 1.1.4 启动Apache服务
1)检查语法
[root@apache /]# /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服务
[root@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端口
[root@apache /]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 108776 root 4u IPv6 157608 0t0 TCP *:http (LISTEN)
httpd 108777 daemon 4u IPv6 157608 0t0 TCP *:http (LISTEN)
httpd 108778 daemon 4u IPv6 157608 0t0 TCP *:http (LISTEN)
httpd 108779 daemon 4u IPv6 157608 0t0 TCP *:http (LISTEN)
[root@apache /]# ps -ef|grep httpd
root 108776 1 0 12:07 ? 00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
daemon 108777 108776 0 12:07 ? 00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
daemon 108778 108776 0 12:07 ? 00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
daemon 108779 108776 0 12:07 ? 00:00:00 /opt/httpd-2.4.37/bin/httpd -k start
root 108863 37886 0 12:08 pts/0 00:00:00 grep httpd 4)Windows访问Apache服务
查看IP地址
[root@apache /]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:A9:47:CC
inet addr:10.90.3.130 Bcast:10.90.3.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea9:47cc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric: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)
安装Apache2.4到此结束!
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com