Apache安装

Apache安装

1).查看一下当前 Linux系统的版本和内核

[root@web001 ~]# cat /etc/redhat-release 
CentOS release 6.4 (Final)
[root@web001 ~]# uname -r
2.6.32-358.el6.x86_64
[root@web001 ~]#


2).查看本机是否安装 httpd 这个软件 也就是 Apache服务


  rpm -e --nodeps 强制卸载软件,不卸载依赖的关联软件


[root@web001 ~]# rpm -qa httpd     //结果是没有安装
[root@web001 ~]#


3).下载 httpd软件 (到官网下载 www.apache.org)

  软件地址: http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.31.tar.gz

[root@web001 tools]# pwd
/root/tools
[root@web001 tools]# wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
--2016-05-06 15:33:54--  http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
Resolving mirrors.hust.edu.cn... 202.114.18.160


4).解压软件

[root@web001 tools]# 
[root@web001 tools]# ll
total 7408
-rw-r--r--. 1 root root 7583841 Jul 17  2015 httpd-2.2.31.tar.gz
[root@web001 tools]# 
[root@web001 tools]# tar xf httpd-2.2.31.tar.gz 
[root@web001 tools]# 
[root@web001 tools]# ll
total 7412
drwxr-xr-x. 11 1000 1000    4096 Jul 16  2015 httpd-2.2.31
-rw-r--r--.  1 root root 7583841 Jul 17  2015 httpd-2.2.31.tar.gz


5).进入 httpd-2.2.31 进行 configure检查配置

./configure \

--prefix=/application/apache2.2.27 \

--enable-deflate \

--enable-expires \

--enable-headers \

--enable-modules=most \

--enable-so \

--enable-rewrite \

--with-mpm=worker

[root@web001 httpd-2.2.31]# pwd
/root/tools/httpd-2.2.31
[root@web001 httpd-2.2.31]# ./configure \
> --prefix=/application/apache2.2.27 \
> --enable-deflate \
> --enable-expires \
> --enable-headers \
> --enable-modules=most \
> --enable-so \
> --enable-rewrite \
> --with-mpm=worker

以上参数讲解一下

./configure \

--prefix=/application/apache2.2.27 \      //Apache服务安装路径在哪里

--enable-deflate \               //服务器响应客户端,数据全部进行压缩,省带宽

--enable-expires \               //缓存过期 客户端请求服务器之后,数据缓存多久

--enable-headers \               //返回响应http响应头信息

--enable-modules=most \            //激活大多数模块功能

--enable-so \                    

--enable-rewrite \               //激活url重写模块  伪静态

--with-mpm=worker                   //进程的方式


 以上检查可能会遇到问题

 # checking for zlib location... not found  提示 zlib软件没有安装 

 解决方案:安装它们就可以了 

[root@web001 httpd-2.2.31]# yum install zlib zlib-devel -y

 再检查一下:运行上面的命令就可以了 不用重新配置   这里只是做上面一样工作

 希望网友们不要误解 这里没有多一步,只是重新检查配置一下 因为第一次检查有软件没有安装到

[root@web001 httpd-2.2.31]# pwd
/root/tools/httpd-2.2.31
[root@web001 httpd-2.2.31]# ./configure \
> --prefix=/application/apache2.2.27 \
> --enable-deflate \
> --enable-expires \
> --enable-headers \
> --enable-modules=most \
> --enable-so \
> --enable-rewrite \
> --with-mpm=worker


6).开始编译源代码 (这里时间有点长)

[root@web001 httpd-2.2.31]# make


7).开始安装软件

[root@web001 httpd-2.2.31]# make install


8).创建一个软链接

[root@web001 ~]# cd /application/apache2.2.27/
[root@web001 apache2.2.27]# ln -s /application/apache2.2.27/ /application/apache


9).检查语法,并开启apache服务

[root@web001 ~]# /application/apache2.2.27/bin/apachectl -t
httpd: Could not reliably determine the server's fully qualified domain name....
Syntax OK
[root@web001 ~]# /application/apache2.2.27/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name....
[root@web001 ~]# //说明 出现上面的错误 我们不要去理会它....没什么大不了的


10).查看80端口是否成功开启

[root@web001 ~]# lsof -i:80
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   5842   root    4u  IPv6  70975      0t0  TCP *:http (LISTEN)
httpd   5844 daemon    4u  IPv6  70975      0t0  TCP *:http (LISTEN)
httpd   5845 daemon    4u  IPv6  70975      0t0  TCP *:http (LISTEN)
httpd   5846 daemon    4u  IPv6  70975      0t0  TCP *:http (LISTEN)


11).关闭防火墙 关闭 SELinux

[root@web001 ~]# /etc/init.d/iptables stop
[root@web001 ~]# setenforce 0
[root@web001 ~]# 
[root@web001 ~]# /etc/init.d/iptables status
iptables: Firewall is not running.                //防火墙关闭
[root@web001 ~]# getenforce 
Permissive                                        //SELinux进入警告模式
[root@web001 ~]#


12).万事俱备,只欠访问......

[root@web001 ~]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Date: Fri, 06 May 2016 08:18:42 GMT
Server: Apache/2.2.31 (Unix) DAV/2
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "1ff10-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html

wKiom1c24zazcSuNAABgfykyI7Q465.jpg



常见问题收藏

1.checking for zlib location... not found

checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

提示  zlib库文件信息没有找到  就是说你的系统里面没有安装这个库


解决方案:

yum install zlib-devel -y

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章