Apache筆記 0105

來源:互聯網
上載者:User

標籤:

Linux下通過server-status監控效能

前提:安裝好Apache,在opt/路徑下

 

  1. 查看Apache的工作模式

 

可以知道是 prefork.c模式

 

  1. 配置server-status 效能

 

進入到httpd.conf路徑

vi  /etc/httpd/conf/httpd.conf

然後添加

<Location /server-status>

    SetHandler   server-status

    Order        allow,deny

    Deny from    nothing

    Allow from   all

</Location>

 

ExtendedStatus On

 

<Location /server-info>

    SetHandler   server-info

    Order        allow,deny

    Deny from    nothing

    Allow from   all

</Location>

  1. 重啟:service httpd restart
  2. 訪問:http://192.168.254.135/server-status

 

Apache的工作模式

1、prefork.c模組(一個非線程型的、預派生的MPM)

2. worker.c模組(支援混合的多線程多進程的多路處理模組)

一般用worker.c 的模式比較多點,支援的並發比較大。

預派生,首先 要申請資源 不夠用的話,再加。

Prefork.c 單進程單線程,比較穩定

Apache的設定檔
  1. 在vi  /etc/httpd/conf/httpd.conf,找到,

ServerRoot "/etc/httpd"

 

查看Apache存放路徑

 

監聽連接埠是:80,預設的,連接埠被佔用,可以更改這個連接埠

 (/DocumentRoot)

系統目錄路徑,應用程式代碼存放的路徑

 

Apache日誌存放路徑

 

 載入設定檔

查看Apache的工作模式

 

1). extra /httpd-mpm.conf

首先:[[email protected] ~]# find / -name extra

可以知道extra在cd /opt/lampp/etc/extra/

能夠查看到Apache的工作模式,

 

2). [[email protected] extra]# cat httpd-info.conf

 查看是否是server-status模組

 ,

3).extra 目錄下, vi httpd-default.conf

Timeout預設是300,超過這個時間就訪問逾時

MaxKeepAliveRequests 100控制長串連最大的請求個數

4) [[email protected] extra]# vi httpd-vhosts.conf

可以配置兩台應用程式相互跳轉

設定Apache工作模式

1.)[[email protected] extra]# vi httpd-mpm.conf

提取檔案

<IfModule mpm_prefork_module>

    StartServers             5

    MinSpareServers          5

    MaxSpareServers         10

    MaxRequestWorkers      150

    MaxConnectionsPerChild   0

</IfModule>

 

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

 

2)[[email protected]extra]# vi /etc/httpd/conf/httpd.conf

拷貝到最後面

<IfModule mpm_prefork_module>

   StartServers             5

   MinSpareServers          5

   MaxSpareServers         10

   MaxRequestWorkers      150

   MaxConnectionsPerChild   0

</IfModule>

 

說明:如果是perfork模式就把httpd-mpm.conf對應的模式拷過來,如果是worker.c就把對應的模組拷貝到httpd.conf

3) 儲存後,重啟

問題:

重啟出現這個?

 

StartServers ,minspareservers改為10,問題解決。

然後訪問:http://192.168.254.135/server-status

可以看到:1 requests currently being processed, 9 idle workers

Apache預設首位進程, 所以有 1 requestscurrently being processed

 

Apache工作模式切換

  要切換到worker模式,則需要登入到linux上,進行如下操作:
  進入/usr/sbin目錄
  cd /usr/sbin
  將當前的prefork模式開機檔案改名
  mv httpd httpd.prefork
  將worker模式的開機檔案改名
  mv httpd.worker httpd
  修改設定檔vi /etc/httpd/conf/httpd.conf

 

 <IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      30
    MaxRequestsPerChild   0
</IfModule>

然後:[[email protected] sbin]# apachectl –l

查看是否切換到 worker.c模式下

Apache筆記 0105

聯繫我們

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