1)确保模块加载:LoadModule status_module modules/mod_status.so
2)开启228行 ExtendedStatus On
3)编辑status区域
<Location /var/www/html/server-status>
SetHandler server-status
Order allow,deny
Allow from 192.168
</Location>
4)检查配置文件正确否,加载服务
5)访问
Apache Server Status for 192.168.1.100
Server Version: Apache/2.2.15 (Unix) DAV/2
Server Built: Jul 24 2015 11:52:28
Current Time: Thursday, 12-May-2016 01:24:37 CST
Restart Time: Thursday, 12-May-2016 01:22:20 CST
Parent Server Generation: 7
Server uptime: 2 minutes 16 seconds
Total accesses: 4 - Total Traffic: 0 kB
CPU Usage: u0 s0 cu0 cs0
.0294 requests/sec - 0 B/second - 0 B/request
1 requests currently being processed, 7 idle workers
____W___........................................................
................................................................
................................................................
................................................................
Scoreboard Key:
10、运行httpd服务的属主和属组
User apache
Group apache
11、使用mod_deflate模块压缩页面优化传输速度
SetOutputFilter DEFLATE
# mod_deflate configuration
# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9
# Netscape 4.x has some problems.
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
三、httpd-2.2 VirtualHost配置
1、基于IP的virtualhost:(事先准备好两个IP)
1)编辑配置文件设置如下:
<VirtualHost 192.168.1.100:80>
DocumentRoot "/web/vhosts/www1"
ServerName www1.a1.com
ErrorLog "/var/log/httpd/www1.err"
CustomLog "/var/log/httpd/www1.access" common
</VirtualHost>
<VirtualHost 192.168.1.101:80>
DocumentRoot "/web/vhosts/www2"
ServerName www2.a2.com
ErrorLog "/var/log/httpd/www2.err"
CustomLog "/var/log/httpd/www2.access" common
</VirtualHost>
2)修改下
DocumentRoot "/web/vhosts/"
3)建立网页文件
[root@linuxidc ~]# mkidr -p /web/vhosts/www1/index.html
[root@linuxidc ~]# mkidr -p /web/vhosts/www2/index.html
4)检查配置文件是否正确,然后重启或加载,ok后测试结果
[root@linuxidc ~]# httpd -t
Syntax OK
[root@linuxidc ~]# service httpd reload
5)查看我们的日志文件
[root@linuxidc ~]# cat /var/log/httpd/www1.access
192.168.1.103 - - [12/May/2016:02:14:04 +0800] "GET / HTTP/1.1" 200 25
[root@linuxidc ~]#
[root@linuxidc ~]#
[root@linuxidc ~]# cat /var/log/httpd/www
www1.access www1.err www2.access www2.err
[root@linuxidc ~]# cat /var/log/httpd/www1.err
2、基于端口的virtualhost