Apache優化深入

**壓力測試 [root@CentOS7-1 ~]# which ab
/usr/bin/ab

ab -n2000 -c800 www.benet.com/index.html

//發送2000請求,併發連接800

可以關閉壓縮功能,觀察測壓結果
**
Apache工作模式

event模式(默認) 查看工作模式 cd /usr/local/httpd/bin
./httpd -l
yum install lsof -y

**lsof -i :80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 2266 root 3u IPv4 15838 0t0 TCP 192.168.100.101:http (LISTEN)
httpd 2267 daemon 3u IPv4 15838 0t0 TCP 192.168.100.101:http (LISTEN)
httpd 2268 daemon 3u IPv4 15838 0t0 TCP 192.168.100.101:http (LISTEN)
httpd 2269 daemon 3u IPv4 15838 0t0 TCP 192.168.100.101:http (LISTEN)

一個root主進程帶有多個daemon子進程**

prefork模式
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--with-mpm=prefork \
--enable-expires \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

**vim /etc/httpd.conf
Include conf/extra/httpd-mpm.conf

vim /usr/local/httpd/conf/extra/httpd-mpm.conf
<IfModule mpm_prefork_module>
StartServers 10 # 啓動時進程數
MinSpareServers 10 # 最小空閒進程數
MaxSpareServers 50 # 最大空閒進程數
MaxRequestWorkers 150 #最大併發進程數
MaxConnectionsPerChild 0 # 最大連接數限制
</IfModule>**

worker模式
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--with-mpm=worker \
--enable-expires \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

**vim /etc/httpd.conf
Include conf/extra/httpd-mpm.conf

<IfModule mpm_worker_module>
StartServers 2 #啓動時進程數
MinSpareThreads 25 #最小空閒線程數
MaxSpareThreads 75 #最大空閒線程數
ThreadsPerChild 25 #每個進程可以啓動的線程數量
MaxRequestWorkers 150 #線程數量最大值
MaxConnectionsPerChild 0 #最大連接數限制
ThreadLimit 64 #每個進程可以啓動的線程數量上限值
</IfModule>
**

**目錄屬性
vim /etc/httpd.conf

<Directory "/usr/local/httpd/htdocs">
Options Indexes FollowSymLinks

AllowOverride None

<RequireAll>
     Require all granted      //允許所有
     Require not ip 192.168.176.140   //不讓176.140訪問
</RequireAll>

</Directory>**

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