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

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