Gxl网
  • 首页
  • 编程
    PHP基础 PHP教程 php框架 JavaScript asp.net AJAX 正则表达式 ASP html代码 css 前端框架 Python 服务器
  • 数据库
    mysql mssql redis 数据库问题
  • 系统教程
    window10教程 window8教程 window11教程 window7教程 windowxp教程 linux教程 U盘教程
  • 操作系统
    Windowsxp windows7 windows8 windows10 其他操作系统
  • 程序下载
    企业程序 小说/有声 网站模板 第三方软件 新闻资讯 第三方源码 小程序 商城源码
  • 框架书籍
    前端开发 服务器端开发 数据库 开发软件 其他手册
  • jquery插件库
    输入 banner图 图片脚本 导航/分类 播放器 css3 jQuery脚本 jqueryhtml5 进度条 贴图/客服
  • 在线工具
    编码转换工具 在线IDE编码工具
  • 开发手册
    linux命令大全 Bootstrap HTML参考手册 css手册/教程 ThinkPHP5.0 ThinkPHP3.2
当前位置:Gxlcms > mysql > 利用squid加速apache

利用squid加速apache

时间:2021-07-01 10:21:17 帮助过:26人阅读

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

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

下载squid apache

wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE4.tar.gz
wget http://labs.xiaonei.com/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 www.zhlinux.com
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 www.zhlinux.com
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 www.zhlinux.com
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

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

  • < 上一篇

    内部类的大概介绍

  • 下一篇 >

    DynamicACL的应用技巧

人气教程排行

  • 355次 1 对数据库模式进行规范化处理,是在数据库设计的什么阶段?
  • 355次 2 mysql如何删除多个表格数据库数据
  • 355次 3 Oracle购买价格和服务费计算方式
  • 355次 4 MYSQL查看和新增表分区
  • 354次 5 TRACE32调试技巧
  • 353次 6 Oracle数据库教程:ORA-01031:权限不足
  • 353次 7 Oracle物化视图失效的几种情况及测试
  • 352次 8 mysql-sql语句查询多个字段不等于零怎么写?
  • 351次 9 如何提高mysql大批量数据更新(update)的效率?
  • 350次 10 mysql如何从ibd文件恢复数据
  • 350次 11 ORACLEROLLUP和CUBE函数
  • 350次 12 IBMDB2赋权[SQL0551N]
  • 350次 13 mysql不等于符号写法
  • 349次 14 redhat8mysql安装具体过程_MySQL
  • 349次 15 SQLServer出现Error:1326错误(管理器无法连接远程数据库)问题解决方案
  • 348次 16 centos下配置mysql数据库自动备份
  • 348次 17 MySQL中使用SQL语句对字段进行重命名
  • 347次 18 数据库中的表以行和列来组织数据,每一行称为每一列称为
  • 347次 19 windowsservice-mysql安装出错,远程调用失败
  • 346次 20 SQL连接查询语法及使用
本站所有资源全部来源于网络,若本站发布的内容侵害到您的隐私或者利益,请联系我们删除!
登录

忘记密码?

登录

看不清楚换一张

注册