论坛风格切换切换到宽版
  • 1783阅读
  • 0回复

DirectAdmin添加mod_cache优化APACHE缓存加速网站 [复制链接]

上一主题 下一主题
离线yangen
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-10-16
mod_cache可以缓存一些常用的静态文件,如:css,js等,以实现网站加速.
下页是安装方法:
进入DA的自定义安装目录

cd /usr/local/directadmin/custombuild
cd configure/ap2
修改config.apache,将原来的:

#!/bin/sh
"./configure" \
    "--prefix=/etc/httpd" \
    "--exec-prefix=/etc/httpd" \
    "--bindir=/usr/bin" \
    "--sbindir=/usr/sbin" \
    "--sysconfdir=/etc/httpd/conf" \
    "--enable-so" \
    "--enable-dav" \
    "--enable-dav-fs" \
    "--enable-dav-lock" \
    "--enable-suexec" \
    "--enable-deflate" \
    "--enable-unique-id" \
    "--with-suexec-caller=apache" \
    "--with-suexec-docroot=/" \
    "--with-suexec-gidmin=100" \
    "--with-suexec-logfile=/var/log/httpd/suexec_log" \
    "--with-suexec-uidmin=100" \
    "--with-suexec-userdir=public_html" \
    "--with-suexec-bin=/usr/sbin/suexec" \
    "--with-included-apr" \
    "--with-pcre=/usr/local" \
    "--includedir=/usr/include/apache" \
    "--libexecdir=/usr/lib/apache" \
    "--datadir=/var/www" \
    "--localstatedir=/var" \
    "--enable-logio" \
    "--enable-ssl" \
    "--enable-rewrite" \
    "--enable-proxy" \
    "--enable-expires" \
    "--with-ssl=/usr" \
    "--enable-headers"\

修改为:

#!/bin/sh
"./configure" \
    "--prefix=/etc/httpd" \
    "--exec-prefix=/etc/httpd" \
    "--bindir=/usr/bin" \
    "--sbindir=/usr/sbin" \
    "--sysconfdir=/etc/httpd/conf" \
    "--enable-so" \
    "--enable-dav" \
    "--enable-dav-fs" \
    "--enable-dav-lock" \
    "--enable-suexec" \
    "--enable-deflate" \
    "--enable-unique-id" \
    "--with-suexec-caller=apache" \
    "--with-suexec-docroot=/" \
    "--with-suexec-gidmin=100" \
    "--with-suexec-logfile=/var/log/httpd/suexec_log" \
    "--with-suexec-uidmin=100" \
    "--with-suexec-userdir=public_html" \
    "--with-suexec-bin=/usr/sbin/suexec" \
    "--with-included-apr" \
    "--with-pcre=/usr/local" \
    "--includedir=/usr/include/apache" \
    "--libexecdir=/usr/lib/apache" \
    "--datadir=/var/www" \
    "--localstatedir=/var" \
    "--enable-logio" \
    "--enable-ssl" \
    "--enable-rewrite" \
    "--enable-proxy" \
    "--enable-expires" \
    "--with-ssl=/usr" \
    "--enable-headers"\
    "--enable-cache" \
    "--enable-disk-cache" \
    "--enable-mem-cache"

也就是在末尾原来配置后面添加

"--enable-cache" \
"--enable-disk-cache" \
"--enable-mem-cache"

然后重新编译apache:

./build apache

编译完apache会自动进行重启,如果发现没有重启,配置没有生效,请手动重启apache

service httpd restart

接下来进行mod_cache优化设置参数
1、输入命令

vi /etc/httpd/conf/extra/httpd-includes.conf

2、添加以下内容:

<IfModule mod_cache.c>
#CacheForceCompletion 100
CacheDefaultExpire 3600
CacheMaxExpire 86400
CacheLastModifiedFactor 0.1
  
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 524288
MCacheMaxObjectCount 10000
MCacheMinObjectSize 1
MCacheMaxObjectSize 51200
</IfModule>
</IfModule>

3、重启apache 使配置生效

service httpd restart

OK,完成配置,现在APACHE通过mod_cache的缓存加速,速度应该快了许多,服务器负载应该下降了。
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个