Ubuntu下的Squid缓存服务器搭建初体验
linux系统:
Ubuntu-maverick-10.10-amd64-server
*选择Ubuntu系统是因为安装软件方便快捷
卸载squid
sudo apt-get purge remove squid
安装squid
sudo aptitude install squid
cd /etc/squid
sudo mv squid.conf squid_bak.conf
sudo vi squid.conf
随意google了个网站测试,代码段:
http_port 80 vhost
cache_dir ufs /var/squid_cache 256 16 256
acl all src 0.0.0.0/0.0.0.0
http_access allow all
#cache_access_log /var/log/squid/access.log
#cache_log /var/log/squid/cache.log
refresh_pattern -i \.css$ 1440 50% 129600 ignore-reload
refresh_pattern -i \.xml$ 1440 50% 129600 ignore-reload
refresh_pattern -i \.html$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.shtml$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.htm$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.jpg$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.png$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.gif$ 1440 90% 129600 ignore-reload
refresh_pattern -i \.bmp$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.js$ 1440 90% 129600 ignore-reload
ESC -》:wq
当时碰到一个问题,没用sudo命令,结果导致修改的东西保存不了,也不知道怎么退出。后来才了解可以使用shift+q,然后输入:q!强退。
重启squid:
sudo /usr/sbin/squid -k parse
sudo /usr/sbin/squid -k reconfigure
*每次修改了squid.conf都需要重启squid才能生效的
/usr/sbin/squid -z
/usr/sbin/squid start
查看网络连接:
netstat -an
查看80端口占用:
sudo lsof -i:80