搞代码 专注于计算机软件代码相关技术文章分享
  • 首页
  • 前端
    • html
    • xml
    • css
    • javascript
    • jquery
  • 后端
    • c语言
    • java
    • asp
    • servlet/jsp
    • php
  • 数据库
    • mysql
    • oracle
    • sqlserver
    • access
  • 实例
    • CSS实战案例大全
    • CSS应用实例(拿来就用)
    • 经典c程序100例【整合】
    • C语言初学者入门讲座
    • jQuery代码示例汇总
  • 下载
    • 文档类下载
    • 工具类下载
    • 代码类下载
    • 技术教程下载
  • 相关文章
  • 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧
> 数据库 > mysql > 利用squid加速apache

利用squid加速apache

mysql 搞代码 4年前 (2022-01-09) 49次浏览 已收录 0个评论

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
Orde本文来源gaodai$ma#com搞$代*码6网r allow,deny
Allow from all
Satisfy all

ServerName http://www.zhlinux.com
ServerAdmin [email protected]
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 http://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 http://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

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


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected]‍,我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:利用squid加速apache

喜欢 (0)赏
[搞代码]
分享 (0)
支持作者一杯咖啡
  • mongodb如何判断字段是否存在
    mongodb如何判断字段是否存在
  • postgresql和mysql语句区别
    postgresql和mysql语句区别
  • mongodb能做缓存吗
    mongodb能做缓存吗
  • postgresql服务起不来怎么办
    postgresql服务起不来怎么办
  • mongodb如何判断字段是否存在
  • postgresql和mysql语句区别
  • mongodb能做缓存吗
  • postgresql服务起不来怎么办
  • postgresql如何备份
  • mongodb服务无法开启怎么办
  • postgresql无法开启怎么办
  • postgresql是什么
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

热门文章

  • 你的PHP代码好骚啊你的PHP代码好骚啊2022-02-280
  • Django 跨域请求处理的示例代码Django 跨域请求处理的示例代码2022-01-090
  • include_once"/include/a.php" 和include_once" . /include/a.php"有什么区别?解决办法include_once"/include/a.php" 和include_once" . /include/a.php"有什么区别?解决办法2022-01-250
  • spring中FactoryBean中的getObject()方法实例解析spring中FactoryBean中的getObject()方法实例解析2022-01-060
  • 详析mysql隐藏空间_mysql详析mysql隐藏空间_mysql2018-06-170
  • MySql的隔离级别跟锁的关系_mysqlMySql的隔离级别跟锁的关系_mysql2018-06-070
  • 版权声明

    本站的文章和资源来自互联网或者站长
    的原创,按照 CC BY -NC -SA 3.0 CN
    协议发布和共享,转载或引用本站文章
    应遵循相同协议。如果有侵犯版权的资
    源请尽快联系站长,我们会在24h内删
    除有争议的资源。
  • 网站驱动

    • 部署在阿里云
    • 由七牛云储存提供 CDN 加速
  • 友情链接

    • 搞代码
    • 宝塔镇河妖
  • 强烈推荐

    • 腾讯云
    • 二三四五
Copyright © 2017-2025 搞代码 | 免责声明 | 桂ICP备16000922号-2 | 网站地图