Apache优化深入
**压力测试 # 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
COMMANDPID USER FD TYPE DEVICE> httpd 2266 root 3uIPv415838 0t0TCP 192.168.100.101:http (LISTEN)
httpd 2267 daemon 3uIPv415838 0t0TCP 192.168.100.101:http (LISTEN)
httpd 2268 daemon 3uIPv415838 0t0TCP 192.168.100.101:http (LISTEN)
httpd 2269 daemon 3uIPv415838 0t0TCP 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
StartServers 10 # 启动时进程数
MinSpareServers 10 # 最小空闲进程数
MaxSpareServers 50 # 最大空闲进程数
MaxRequestWorkers 150 #最大并发进程数
MaxConnectionsPerChild 0 # 最大连接数限制
**
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
StartServers 2 #启动时进程数
MinSpareThreads 25 #最小空闲线程数
MaxSpareThreads 75 #最大空闲线程数
ThreadsPerChild 25 #每个进程可以启动的线程数量
MaxRequestWorkers 150 #线程数量最大值
MaxConnectionsPerChild 0 #最大连接数限制
ThreadLimit 64 #每个进程可以启动的线程数量上限值
**
**目录属性
vim /etc/httpd.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted //允许所有
Require not ip 192.168.176.140 //不让176.140访问
**
页:
[1]