Wol*_*ahl 5 apache mediawiki caching squid
为了加快MediaWiki网站的速度,该网站的内容使用了大量的模板,但是当模板完成了他们的工作时,他们几乎有静态内容我想设置一个squid服务器看看
https://www.mediawiki.org/wiki/Manual:PurgeList.php
和
https://www.mediawiki.org/wiki/Manual:Squid_caching
然后通过使用脚本执行wget/curl调用来"自动"填充squid服务器的缓存,该调用将触及Mediawiki的所有页面.我的期望是,在这个程序之后,每个页面都在squid缓存中(如果我足够大),然后每个访问都将由squid完成.
我怎么会这样工作? 例如:
到目前为止我尝试了什么
我开始时找出如何使用以下方法安装鱿鱼:
和
我通过ifconfig eth0找到了我的ip地址xx.xxx.xxx.xxx(这里没有透露)
在/etc/squid3/squid.conf我放了
http port xx.xxx.xxx.xxx:80 transparent vhost defaultsite=XXXXXX
cache_peer 127.0.0.1 parent 80 3130 originserver
acl manager proto cache_object
acl localhost src 127.0.0.1/32
# Allow access to the web ports
acl web_ports port 80
http_access allow web_ports
# Allow cachemgr access from localhost only for maintenance purposes
http_access allow manager localhost
http_access deny manager
# Allow cache purge requests from MediaWiki/localhost only
acl purge method PURGE
http_access allow purge localhost
http_access deny purge
# And finally deny all other access to this proxy
http_access deny all
Run Code Online (Sandbox Code Playgroud)
然后我配置了我的apache2服务器
# /etc/apache2/sites-enabled/000-default.conf
Listen 127.0.0.1:80
Run Code Online (Sandbox Code Playgroud)
我补充道
$wgUseSquid = true;
$wgSquidServers = array('xx.xxx.xxx.xxx');
$wgSquidServersNoPurge = array('127.0.0.1');
Run Code Online (Sandbox Code Playgroud)
到我的LocalSettings.php
然后我重新启动了apache2并启动了squid3
service squid3 restart
Run Code Online (Sandbox Code Playgroud)
并做了第一次访问尝试
wget --cache=off -r http://XXXXXX/mediawiki
Run Code Online (Sandbox Code Playgroud)
结果是:
Resolving XXXXXXX (XXXXXXX)... xx.xxx.xxx.xxx
Connecting to XXXXXXX (XXXXXXX|xx.xxx.xx.xxx|:80... failed: Connection refused.
Run Code Online (Sandbox Code Playgroud)
假设 Apache 2.x。
虽然与 Squid 无关,但您可以仅使用 Apache 模块来实现此目的。在这里查看 mod_cache: https://httpd.apache.org/docs/2.2/mod/mod_cache.html
您只需将其添加到 Apache 配置中,并要求 Apache 对渲染内容进行磁盘缓存。
您需要确保您的内容在生成的 PHP 响应中具有适当的缓存过期信息,MediaWiki 应该为您处理这个问题。
添加这样的缓存层可能不会达到预期的结果,因为该层不知道页面是否已更改,缓存管理在这里很困难,并且只能用于实际的静态内容。
乌班图:
a2enmod cache cache_disk
Run Code Online (Sandbox Code Playgroud)
阿帕奇配置:
CacheRoot /var/cache/apache2/mod_disk_cache
CacheEnable disk /
Run Code Online (Sandbox Code Playgroud)
我不建议通过访问每个页面来预先填充缓存。这只会导致休眠(不经常使用)的页面占用宝贵的空间/内存。如果你仍然想这样做,你可以看看 wget:
Description from: http://www.linuxjournal.com/content/downloading-entire-web-site-wget
$ wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
www.website.org/tutorials/html/
This command downloads the Web site www.website.org/tutorials/html/.
The options are:
--recursive: download the entire Web site.
--domains website.org: don't follow links outside website.org.
--no-parent: don't follow links outside the directory tutorials/html/.
--page-requisites: get all the elements that compose the page (images, CSS and so on).
--html-extension: save files with the .html extension.
--convert-links: convert links so that they work locally, off-line.
--restrict-file-names=windows: modify filenames so that they will work in Windows as well.
--no-clobber: don't overwrite any existing files (used in case the download is interrupted and
resumed).
Run Code Online (Sandbox Code Playgroud)
更好的选择:Memcached
MediaWiki 还支持使用 Memcached 作为仅用于数据和模板的非常快速的内存缓存服务。这不像 Squid 或 Apache mod_cache 这样的网站范围缓存那么残酷。MediaWiki 将管理 Memcached,以便任何更改都会立即反映在缓存存储中,这意味着您的内容将始终有效。
请在此处查看 MediaWiki 上的安装说明: https: //www.mediawiki.org/wiki/Memcached
我的建议是不要使用 Apache mod_cache 或 Squid 来完成此任务,而是安装 Memcached 并配置 MediaWiki 来使用它。
| 归档时间: |
|
| 查看次数: |
260 次 |
| 最近记录: |