手工編譯安裝Apache

來源:互聯網
上載者:User

標籤:編譯安裝apache 安裝apache httpd

實驗要求:手工編譯安裝Apache


實驗步驟:

伺服器(Redhat6)地址:192.168.4.2 

客戶機(Win7)地址:192.168.4.5


客戶機設定LAMP檔案夾共用,安裝檔案在LAMP檔案夾中


mount.cifs //192.168.4.5/LAMP /opt/lamp //將LAMP檔案夾掛載到伺服器中的lamp目錄中


smbclient -L 192.168.4.5 查看已經共用到的LAMP檔案夾


tar xzvf httpd-2.4.2.tar.gz -C /opt/http 將主程式httpd解壓到http目錄中


tar xzvf apr-1.4.6.tar.gz -C /opt/http 將附加程式解壓到http中

tar xzvf apr-util-1.4.1.tar.gz -C /opt/http


cp -R  apr-1.4.6.tar.gz /opt/http/httpd-2.4.2/srclib/apr 將歸檔包複製到相應的目錄下

cp -R  apr-util-1.4.1.tar.gz /opt/http/httpd-2.4.2/srclib/apr-util


安裝httpd之前要安裝apr和apr-util否則會報錯not found


cd /opt/http/apr-1.4.6 一定要切換到該程式的原始碼目錄中執行配置否則報錯

./configure --prefix=/usr/local/apr  指定安裝路徑(這個路徑一定要已存在的)

make

make install


cd /opt/http/apr-util-1.4.1

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config 

make

make install


cd /opt/http/httpd-2.4.2

./configure \

--prefix=/usr/local/apache \

--with-apr=/usr/local/apr/bin/apr-1-config \

--with-apr-util=/usr/local/apr-util/bin/apu-1-config \

--enable-so \

--enable-rewrite \

--enable-mods-shared=most \

--with-mpm=worker \

--disable-cgid \

--disable-cgi


如果檢查安裝的時候會提示error,原因可能是缺少gcc,gcc-c++,pcre(pcre有2個包,一個基本包還有一個devel包,都要安裝)



建立yum倉庫

cd /etc/yum.repo.d/

vi httpd.repo 為安裝缺少的軟體建立一個新的yum


[httpd]  #檔案名稱

name=httpd   #倉庫命名描述

baseurl=file:///mnt  #定義安裝包路徑

enabled=1   #開啟使用者倉庫

gpgcheck=0  #不檢查軟體KEY

:wq  #儲存退出


進入/mnt/Packages中yum install XXX(gcc等) -y安裝(擺脫依賴性關係的安裝)


這些都安裝成功之後,再次進入httpd-2.4.2目錄下繼續上一步檢查安裝,沒有error則可以繼續make,make install


驗證安裝成功可以ls /usr/local/Itapache可以看到各種已經安裝好的子目錄


添加httpd系統服務


cp /usr/local/apache/bin/apachectl /etc/init.d/httpd 將apachectl指令碼複製為/etc/init.d/httpd


vi /etc/init.d/httpd 在檔案最前面插入下面的行

#!/bin/sh

    # chkconfig:35 85 15 設定服務啟動層級,3,5中啟動

    # description:Apache is a World 儲存退出


ls -ld /etc/init.d/httpd 查看這個檔案的許可權,如果沒有執行許可權,則需要添加

chmod +x /etc/init.d/httpd


chkconfig --add httpd 添加httpd系統服務

chkconfig --list httpd 可以看到httpd服務的啟動狀態,3,5開啟


vi /usr/local/apache/conf/httpd.conf 配置httpd服務


找到並設定以下兩行內容

Listen:80

Servername:www.benet.com



service httpd start 啟動httpd服務

netstat -anpt 可看到已監聽80連接埠


在客戶機(192.168.4.5)瀏覽器中輸入伺服器網址,則會顯示web網站的頁面內容It works!


如果輸入www.benet.com則還需要對伺服器的DNS服務做配置:配置/etc/hosts,/etc/resolv.conf,/var/named/benet.com.zone檔案

另外還需要配置關閉防火牆service iptables stop和setenforce 0 將客戶機的首選DNS配置為192.168.4.2

關於怎樣配置DNS網路服務將在另外一篇文檔中詳細描述。

ps:在安裝Apache的過程中有可能會出現各種意想不到的錯誤,一定要沉著冷靜的分析錯誤提示,並且查看系統日誌尋求解決方案


本文出自 “挨踢女的網路成長之路” 部落格,請務必保留此出處http://shengjie.blog.51cto.com/8734352/1580302

手工編譯安裝Apache

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.