httpd安裝配置

來源:互聯網
上載者:User

標籤:httpd安裝配置


www.httpd.apace.org

httpd:

 事先建立進程

 按需維持適當的進程

 模組設計,核心比較小,各種功能都模組添加

     支援回合組態,支援單獨編譯模組

支援多種方式的虛擬機器主機配置

Socket  IP:Port

   虛擬機器主機:

    基於IP的虛擬機器主機;

    基於連接埠的虛擬機器主機;

    基於網域名稱的虛擬機器主機;

支援https協議 (mod_ssl)

支援使用者認證

支援基於IP或主機名稱的acl

支援每個目錄的存取控制

支援URL重寫,/image/a.jpeg, /bbs/images/a.jpeg

安裝:

 1.rpm包

 2.源碼編譯

 httpd:SELinux(事先關閉)

 httpd:

    /usr/sbin/httpd(MPM:prefork)

httpd: root:root 主導進程,管理空閑進程(master process)

httpd: apche:apche (worker process))

/etc/rc.d/init.d/httpd

Port: (80/tcp),(ssl:443/tcp)

/etc/httpd:工作的根目錄,相當於程式安裝的目錄

/etc/httpd/conf:設定檔目錄

             主設定檔:httpd.conf

   /etc/httpd/conf.d/*.conf 

    /etc/httpd/modules:模組目錄

/etc/httpd/logs--> /var/log/httpd:日誌目錄

記錄檔有兩類:訪問日誌access_log,錯誤記錄檔:err_log

/var/www/

        html靜態類容使用的路勁

cgi-bin動態類容使用的路勁


[[email protected] ~]# yum -y install httpd

service httpd start        

[[email protected] ~]# ps aux |grep httpd 已經啟動了多個空閑進程來準備相應客戶

root      1848  0.0  0.3  11372  3332 ?        Ss   09:24   0:00 /usr/sbin/httpd

apache    1850  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1851  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1852  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1853  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1854  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1855  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1856  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

apache    1857  0.0  0.2  11372  2116 ?        S    09:24   0:00 /usr/sbin/httpd

root      1867  0.0  0.0   5976   728 pts/1    S+   09:28   0:00 grep httpd

[[email protected] yum.repos.d]# vim /etc/httpd/conf.d/welcome.conf 預設歡迎介面

[[email protected] yum.repos.d]# cd/etc/httpd/conf

[[email protected] conf]# cp httpd.conf  httpd.conf.back 備份一下原有的設定檔

[[email protected] conf]# grep "Section" httpd.conf

### Section 1: Global Environment

### Section 2: ‘Main‘ server configuration 主伺服器段。和虛擬機器主機不能同時生效

### Section 3: Virtual Hosts 虛擬機器主機

[[email protected] conf]# vim httpd.conf

由指令和參數組成。指令不區分大小寫

value則根據需要有可能要區分

[[email protected] conf]# yum -y install httpd-manual 安裝此包可以自動組建組態檔案

[[email protected] conf.d]# cd /etc/httpd/conf.d/

[[email protected] conf.d]# vim manual.conf 

[[email protected] conf.d]# service httpd restart 改了設定檔後都需要重啟伺服器

http://192.168.10.2/manual

URL Rewriting Guide 指令參考


預設地,伺服器HTTP回應標頭會包含apache和php版本號碼。像下面的,這是有危害的,因為這會讓駭客通過知道詳細的版本號碼而發起已知該版本的漏洞攻擊。
1.Server: Apache/2.2.17 (Unix) PHP/5.3.5
為了阻止這個,需要在httpd.conf設定ServerTokens為Prod,這會在回應標頭中顯示“Server:Apache”而不包含任何的版本資訊。
1.# vi httpd.conf
2.ServerTokens Prod
下面是ServerTokens的一些可能的賦值:
ServerTokens Prod 顯示“Server: Apache”
ServerTokens Major 顯示 “Server: Apache/2″
ServerTokens Minor 顯示“Server: Apache/2.2″
ServerTokens Min 顯示“Server: Apache/2.2.17″
ServerTokens OS 顯示 “Server: Apache/2.2.17 (Unix)”
ServerTokens Full 顯示 “Server: Apache/2.2.17 (Unix) PHP/5.3.5″ (如果你這指定任何的值,這個是預設的返回資訊)

3.ServerRoot "/etc/httpd"伺服器的工作目錄

4.PidFile  run/httpd.pid 進程的PID號,儲存位置在 /etc/httpd/run/httpd.pid

5.Timeout 120 逾時間,使用者三向交握的等待時間

6.KeepAlive 0ff 是否使用長串連,只要伺服器訪問了不是很大,開啟長串連可以提高效率

7.MaxKeepAliveRequests 100   開啟長串連使用者最多可以一次請求100個資源,設定為0代表無限次

8.KeepAliveTimeout 15 長串連的斷開時間長度


LoadRunner測試伺服器的工具


MPM多道處理模組

mpm_winnt 是專門針對Windows NT最佳化的MPM(多路處理模組),它使用一個單獨的父進程產生一個單獨的子進程,在這個子進程中輪流產生多個線程來處理請求。也就是說 mpm_winnt只能啟動父子兩個進程, 不能像Linux下那樣同時啟動多個進程。

prefork 一個請求用一個進程響應 ,穩定可靠。效能差

worker  一個請求用一個線程響應,啟動多個進程,每個進程產生多個線程

event 一個進程處理多個請求

[[email protected] conf.d]# rpm -ql httpd |grep bin

/usr/sbin/apachectl

/usr/sbin/htcacheclean

/usr/sbin/httpd

/usr/sbin/httpd.event

/usr/sbin/httpd.worker

/usr/sbin/httxt2dbm

/usr/sbin/rotatelogs

/usr/sbin/suexec

/var/www/cgi-bin

/var/www/icons/binary.gif

/var/www/icons/binary.png

/var/www/icons/binhex.gif

/var/www/icons/binhex.png

/var/www/icons/small/binary.gif

/var/www/icons/small/binary.png

/var/www/icons/small/binhex.gif

/var/www/icons/small/binhex.png

[[email protected] conf.d]# vim /etc/sysconfig/httpd 

HTTPD=/usr/sbin/httpd.worker 啟用以後伺服器改成worker模型

[[email protected] conf.d]# vim /etc/httpd/conf/httpd.conf 定義的模型

# prefork MPM

......

<IfModule prefork.c>

StartServers       8   伺服器剛開機時定義幾個空閑進程

MinSpareServers    5   最少幾個空閑進程

MaxSpareServers   20   最大空閑進程

ServerLimit      256   最大用戶端數

MaxClients       256   指定ServerLimit上限

MaxRequestsPerChild  4000  每個子進程最多可以響應多少次

</IfModule>


# worker MPM

......

<IfModule worker.c>

StartServers         4

MaxClients         300

MinSpareThreads     25 最小空閑線程

MaxSpareThreads     75 最大空閑線程

ThreadsPerChild     25  一個進程產生多少個線程   

MaxRequestsPerChild  0 每個進程最多響應多少個請求0表示不限定

</IfModule>


Listen指定監聽的地址和連接埠,可以同時監聽多個連接埠列如

Listen 80

Listen 8080


LoadModule指定httpd服務啟動時裝載的模組



本文出自 “linux營運” 部落格,謝絕轉載!

httpd安裝配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.