本次安装版本为4.17版本,在此之前安装5.9版本启动时起不来,然后还不报错(目前来看原因应该是缺少squid用户的问题),所以退而求次,安装4.17版本
1、上传squid-4.17.tar.gz到服务器data目录下
2、解压并建立squid文件夹
[root@zonghe03 data]# mkdir squid
[root@zonghe03 data]# tar zxvf squid-4.15.tar.gz
[root@zonghe03 data]# ll
total 10544
drwx------ 2 root root 16384 Jul 7 11:11 lost+found
drwxr-xr-x 8 root root 4096 Jul 7 15:52 squid
drwxr-xr-x 16 1000 1000 4096 Jul 7 15:40 squid-4.17
-rw-r--r-- 1 root root 5292674 Jul 7 15:37 squid-4.17.tar.gz
drwxr-xr-x 16 1000 1000 4096 Jul 7 15:17 squid-5.9
-rw-r--r-- 1 root root 5471615 Jul 6 18:05 squid-5.9.tar.gz
3、进入解压后的squid-4.17 进行配置 安装
[root@zonghe03 data]# cd squid-4.17
[root@zonghe03 squid-4.17]# ./configure --prefix=/data/squid --sysconfdir=/data/squid/config --enable-linux-netfilter
[root@zonghe03 data]# make
[root@zonghe03 data]# make install
4、进入data/sbin启动 这时候就出现问题了
[root@zonghe03 sbin]# ./squid
WARNING: Cannot write log file: /data/squid/var/logs/cache.log
/data/squid/var/logs/cache.log: Permission denied
messages will be sent to 'stderr'.
根据报错然后结合百度知道是缺少squid且没权限的问题,那我们就进行建用户和赋权限
5、查看是否有squid用户
[root@zonghe03 data]# cat /etc/passwd
发现没有
进行建用户
[root@zonghe03 squid]# useradd -M -s /sbin/nologin squid
[root@zonghe03 squid]# cat /etc/passwd
这时候就有squid用户了
[root@zonghe03 squid]# chown -R squid:squid /data/squid/
[root@zonghe03 squid]# ll
total 24
drwxr-xr-x 2 squid squid 4096 Jul 7 15:52 bin
drwxr-xr-x 2 squid squid 4096 Jul 7 15:52 config
drwxr-xr-x 2 squid squid 4096 Jul 7 15:52 libexec
drwxr-xr-x 2 squid squid 4096 Jul 7 15:52 sbin
drwxr-xr-x 5 squid squid 4096 Jul 7 15:52 share
drwxr-xr-x 5 squid squid 4096 Jul 7 15:52 var
[root@zonghe03 data]# chmod -R 777 squid/
查看版本
[root@zonghe03 squid]# ./sbin/squid -v
Squid Cache: Version 4.17
Service Name: squid
configure options: '--prefix=/data/squid' '--sysconfdir=/data/squid/config' '--enable-linux-netfilter' --enable-ltdl-convenience
6、启动
[root@zonghe03 squid]# ./sbin/squid
[root@zonghe03 squid]# ps -ef |grep squid
root 18874 1 0 16:05 ? 00:00:00 ./sbin/squid
nobody 18876 18874 0 16:05 ? 00:00:00 (squid-1) --kid squid-1
nobody 18877 18876 0 16:05 ? 00:00:00 (logfile-daemon) /data/squid/var/logs/access.log
root 18920 19687 0 16:05 pts/1 00:00:00 grep --color=auto squid
7、配置客户端进行验证
在另一台机器的profice进行配置
[root@zonghe02 ~]# vim /etc/profile
http_proxy=http://172.xx.xxx.xx:3128
https_proxy=http://172.xx.xxx.xx:3128
no_proxy=172.xx.xxx.,xx.255.xx.xx
[root@zonghe02 ~]# source /etc/profile
[root@zonghe02 ~]# curl www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>缇搴︿镐革间綘灏辩ラ</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129>