好得很程序员自学网
  • 首页
  • 后端语言
    • C#
    • PHP
    • Python
    • java
    • Golang
    • ASP.NET
  • 前端开发
    • Angular
    • react框架
    • LayUi开发
    • javascript
    • HTML与HTML5
    • CSS与CSS3
    • jQuery
    • Bootstrap
    • NodeJS
    • Vue与小程序技术
    • Photoshop
  • 数据库技术
    • MSSQL
    • MYSQL
    • Redis
    • MongoDB
    • Oracle
    • PostgreSQL
    • Sqlite
    • 数据库基础
    • 数据库排错
  • CMS系统
    • HDHCMS
    • WordPress
    • Dedecms
    • PhpCms
    • 帝国CMS
    • ThinkPHP
    • Discuz
    • ZBlog
    • ECSHOP
  • 高手进阶
    • Android技术
    • 正则表达式
    • 数据结构与算法
  • 系统运维
    • Windows
    • apache
    • 服务器排错
    • 网站安全
    • nginx
    • linux系统
    • MacOS
  • 学习教程
    • 前端脚本教程
    • HTML与CSS 教程
    • 脚本语言教程
    • 数据库教程
    • 应用系统教程
  • 新技术
  • 编程导航
    • 区块链
    • IT资讯
    • 设计灵感
    • 建站资源
    • 开发团队
    • 程序社区
    • 图标图库
    • 图形动效
    • IDE环境
    • 在线工具
    • 调试测试
    • Node开发
    • 游戏框架
    • CSS库
    • Jquery插件
    • Js插件
    • Web框架
    • 移动端框架
    • 模块管理
    • 开发社区
    • 在线课堂
    • 框架类库
    • 项目托管
    • 云服务

当前位置:首页>数据库技术>MYSQL
<tfoot draggable='sEl'></tfoot>

利用squid加速apache

apache(81端口) squid(80端口)(apache和squid跑在同一个机器上面 要实现反向代理 )我将我的外网域名用zhlinux测试数据代替了 下载squid apache wget http://HdhCmsTestsquid-cache.org/Versions/v3/3.0/squid-3.0.STABLE4.tar.gz wget http://labs.xiaonei测试数据/apach

apache(81端口) squid(80端口)(apache和squid跑在同一个机器上面 要实现反向代理 )我将我的外网域名用zhlinux测试数据代替了

下载squid apache

wget http://HdhCmsTestsquid-cache.org/Versions/v3/3.0/squid-3.0.STABLE4.tar.gz
wget http://labs.xiaonei测试数据/apache-mirror/httpd/httpd-2.2.14.tar.gz

安装apache

tar zxvf httpd-2.2.14.tar.gz

cd httpd-2.2.14

./configure --prefix=/usr/local/apache2

make&&make install

配置参数可以根据自己的需求来

apache配置如下:
Listen 81
NameVirtualHost *


Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Satisfy all


ServerName HdhCmsTestzhlinux测试数据
ServerAdmin wenmin@wvuu.net
DocumentRoot "/usr/local/apache2/htdocs/"
DirectoryIndex index.html
# ErrorLog "/usr/local/apache/logs/abc-error_log"
# SetEnvIf Remote_Addr "::1" dontlog
# CustomLog "/usr/local/apache/logs/abc-access_log" combined env=!dontlog

启动apache
查看监听端口

netstat -ntpl | grep 81

安装squid

useradd squid
tar zxvf squid-3.0.STABLE4.tar.gz

cd squid-3.0.STABLE4

./configure --prefix=/usr/local/squid --disable-carp --with-aufs-threads=32 --with-pthreads --enable-storeio='ufs,aufs,coss,null' --enable-disk-io='AIO,Blocking' --enable-removal-policies='heap,lru' --disable-wccp --enable-kill-parent-hack --disable-snmp --disable-poll --disable-select --enable-auth=basic --with-aio --disable-ident-lookup --with-filedescriptors=65536

make&&make install

cd /usr/local/squid/var/logs/
touch cache.log
chmod 755 cache.log
chown squid:squid cache.log
touch page_zs_access_log
chmod 755 page_zs_access_log
chown squid:squid page_zs_access_log

配置squid.conf文件

vi /usr/local/squid/etc/squid.conf

visible_hostname HdhCmsTestzhlinux测试数据
http_port 80 vhost vport
cache_mem 512 MB
maximum_object_size_in_memory 2048 KB
memory_replacement_policy lru
cache_dir ufs /tmp 512 16 256
max_open_disk_fds 0
minimum_object_size 0 KB
maximum_object_size 32768 KB
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs % h" "%{User-Agent}>h" %Ss:%Sh
access_log /usr/local/squid/var/logs/page_zs_access_log combined
pid_filename /usr/local/squid/var/logs/squid.pid
cache_store_log none
cache_peer 127.0.0.1 parent 81 0 no-query no-digest originserver name=www
cache_peer_domain www HdhCmsTestzhlinux测试数据
cache_peer_access www allow all
http_access allow all
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe
cache deny QUERY
cache_effective_user squid
cache_effective_group squid

验证squid.conf配置是否正确
/usr/local/squid/sbin/squid -k parse

如果没有问题会显示
/usr/local/squid/etc/squid.conf (depth 0)

/usr/local/squid/sbin/squid -z
用来Creating Swap Directories

创建squid启动脚本

vi squid.sh

#!/bin/sh
#
ulimit -HSn 15000
# this script starts and stops Squid
echo 15000 > /proc/sys/fs/file-max
case "$1" in
start)
/usr/local/squid/sbin/squid -s
echo -n ' Squid'
;;
stop)
/usr/local/squid/sbin/squid -k shutdown
;;
esac
赋予执行权限

chmod x squid.sh

./squid.sh start

查看有没有启动
#ps fax|grep squid
13750 pts/3 S 0:00 \_ grep squid
30474 ? Ss 0:00 /usr/local/squid/sbin/squid -s
30476 ? S 0:01 \_ (squid) -s
则证明OK

more /usr/local/squid/var/logs/page_zs_access_log |grep TCP_MEM_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到内存中,并返回给访问用户

more /usr/local/squid/var/logs/page_zs_access_log |grep TCP_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到cache目录中,并返回给访问用户

可以查看下命中率及其他相关信息
#/usr/local/squid/bin/squidclient -p 80 -h localhost mgr:info

说明:本文档是参照网络上一些文档而写。

查看更多关于利用squid加速apache的详细内容...

声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did159792
更新时间:2022-12-08   阅读:36次

上一篇: DynamicACL的应用技巧

下一篇:内部类的大概介绍

最新资料更新

  • 1.MySQL Query Cache导入查询缓慢解决办法
  • 2.什么是sql注入漏洞
  • 3.MySQL数据库线上修改表结构的方法
  • 4.MySQL入门教程之参数配置(my.ini配置)
  • 5.MySQL移动、重新命名数据表的方法
  • 6.mysql语句转义,sql特殊字符转义(sql防注入)
  • 7.mysql定时任务 Event Scheduler用法详解
  • 8.如何备份mysql?
  • 9.MySql各种查询方式详解
  • 10.sql语句的作用是什么?
  • 11.mysql查看表是否被锁
  • 12.centos增加mysql连接数方法详解
  • 13.MySQL数据库的创建选择与删除命令详解
  • 14.sqlserver是免费的吗?
  • 15.MySQL数据库存储引擎介绍及数据库的操作详解
  • 16.分享mysql多字段模糊查询优化代码
  • 17.如何彻底删除sql2008
  • 18.SQL如何使用正则表达式对数据进行过滤
  • 19.mysql怎么去掉表中重复的字段
  • 20.mysql支持分布式吗

CopyRight:2016-2025好得很程序员自学网 备案ICP:湘ICP备09009000号-16 http://www.haodehen.cn
本站资讯不构成任何建议,仅限于个人分享,参考须谨慎!
本网站对有关资料所引致的错误、不确或遗漏,概不负任何法律责任。
本网站刊载的所有内容(包括但不仅限文字、图片、LOGO、音频、视频、软件、程序等)版权归原作者所有。任何单位或个人认为本网站中的内容可能涉嫌侵犯其知识产权或存在不实内容时,请及时通知本站,予以删除。

网站内容来源于网络分享,如有侵权发邮箱到:kenbest@126.com,收到邮件我们会即时下线处理。
网站框架支持:HDHCMS   51LA统计 百度统计
Copyright © 2018-2025 「好得很程序员自学网」
[ SiteMap ]