永发信息网

如何才能让squid配置文件中'dns

答案:2  悬赏:60  手机版
解决时间 2021-03-07 13:47
  • 提问者网友:抽煙菂渘情少年
  • 2021-03-06 22:22
如何才能让squid配置文件中'dns
最佳答案
  • 五星知识达人网友:走死在岁月里
  • 2021-03-06 22:32
1、首先下载:squid-3.2.9.tar.bz2
2、上传到服务器后解压:
解压: tar -vxjf squid-3.2.9.tar.bz2
解压后生成目录:squid-3.2.9
进入目录翻看文档INSTALL:
xxxx> more INSTALL
To build and install the Squid Cache, type:
% ./configure --prefix=/usr/local/squid
% make all
% make install
To run a Cache, you will need to:
1. customize the squid.conf configuration file:
% vi /usr/local/squid/etc/squid.conf
2. Initalise the cache:
% /usr/local/squid/sbin/squid -z
3. start the cache:
% /usr/local/squid/sbin/squid
If you want to use the WWW interface to the Cache Manager, copy
the cachemgr.cgi program into your httpd server's cgi-bin
directory.
3、安装步骤:
./configure --prefix=/usr/local/squid
make all
sudo make install(因为要拷贝到系统目录,需要root权限,所以sudo了,你也可以root登录执行,我是Ubuntu的系统,所以用sudo,有root权限就行)
检查配置文件:
sudo vi /usr/local/squid/etc/squid.conf
配置项1:
# Squid normally listens to port 3128
http_port 3128
配置项2:
acl localnet src 192.168.0.0/16
http_access allow localnet
配置项3:
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /usr/local/squid/var/cache/squid 100 16 128
cache_mem 32 MB (这一条必须配置)
否则就会遭遇报错: 2013/10/12 16:16:55 kid1| WARNING cache_mem is larger than total disk cache space!
安装好了以后,系统中新建了一个用户squid,在组中一查,发现属于nobody组的:
cat /etc/passwd|grep squid
cat /etc/group|grep 65534
安装squid的所在目录是:/usr/local/squid
直接改了所属用户为squid:nobody
sudo chown -Rf squid:nobody /usr/local/squid
建立cache的时候,对下面目录需要nobody用户权限:
sudo chown -Rf nobody /usr/local/squid/var/cache/
sudo chown -Rf nobody /usr/local/squid/var/logs/
否则会遭遇:
WARNING: Cannot write log file: /usr/local/squid/var/logs/cache.log
FATAL: Failed to make swap directory /usr/local/squid/var/cache/squid/00: (13) Permission denied
初始化squid.conf里配置的cache目录,就是建立了一堆的目录:
sudo /usr/local/squid/sbin/squid -z
在前台启动squid,并输出启动过程
sudo /usr/local/squid/sbin/squid -N -d1
显示ready to server reques,则启动成功。可以键入ctrl+c,停止squid,并以后台运行的方式启动。
没有在配置文件中配置DNS,而是在 /etc/resolv.conf 中配置:
domain site
nameserver x.x.x.x
所以打印出来的日志中就这样的:
2013/10/12 16:42:13| Adding nameserver x.x.x.x from /etc/resolv.conf
squid从这个配置文件中读取了dns配置来用。
启动squid后台运行
sudo /usr/local/squid/sbin/squid -s
检查一下进程是否存在:ps -ef|grep squid
通过squid客户端查看squid运行状态
/usr/local/squid/bin/squidclient -h 127.0.0.1 -p 3128 mgr:info
全部回答
  • 1楼网友:怙棘
  • 2021-03-07 00:11
搜一下:如何才能让squid配置文件中'dns
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯