17.
this is an ubuntu thing. The developers proposed a patch to apply at compile time, but I think it’s easier to do this:
sudo ln -s /var/log /var/logs
18.
As I mentioned earlier, we’re gonna use coss method, read all about it on the squid website. If you have files bigger than 1MB, you might want to use coss for small files and aufs for bigger ones. But that’s later, right now we’ll create a 20GB “partition” for coss.
sudo dd if=/dev/zero bs=1048576 count=20000 of=/var/spool/squid/coss
runs for about 6-7 minutes. do not interrupt!!
19.
Next we’re gonna set up squirm, if you’re not interested in that - skip this section.
sudo tar xzf squirm-1.26.tgz
20.
cd squirm-1.26/
21.
sudo nano Makefile
22.
Note, that I didn’t have the time to mess with groups, so I just removed it. Maybe you should deal with it afterall.Change the following:
USER=nobody #GROUP=squid install -m 755 -o root -g $(ROOT_GROUP) -d $(PREFIX) \ $(PREFIX)/bin install -m 770 -o root -d $(PREFIX)/etc install -m 750 -o $(USER) -d $(PREFIX)/logs install -m 660 -c -o root squirm.conf.dist squirm.patterns.dist \ $(PREFIX)/etc install -m 755 -o root -g $(ROOT_GROUP) --strip squirm $(PREFIX)/bin
23.
sudo make
24.
sudo make install
25.
Let’s continue with squid. Pay attention that I chmoded the whole thing 777, but it’s better to find the right one. Otherwise it’s not really safe now, is it?
sudo chmod -R 777 /var/log sudo chmod -R 777 /var/logs sudo chmod -R 777 /var/spool
26.
The next file is copied from a packaged installation - works great. Again, remove the backslashed near the quote signs, otherwise it will NOT work!!
sudo nano /etc/init.d/squid
27.
<code>#! /bin/sh
#
# squid Startup script for the SQUID HTTP proxy-cache.
#
# Version: @(#)squid.rc 2.20 01-Oct-2001 miquels@cistron.nl
#
### BEGIN INIT INFO
# Provides: squid
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start: $named
# Should-Stop: $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Squid HTTP Proxy
### END INIT INFO
NAME=squid
DAEMON=/usr/sbin/squid
LIB=/usr/lib/squid
PIDFILE=/var/run/$NAME.pid
SQUID_ARGS=\"-D -YC\"
[ ! -f /etc/default/squid ] || . /etc/default/squid
. /lib/lsb/init-functions
PATH=/bin:/usr/bin:/sbin:/usr/sbin
[ -x $DAEMON ] || exit 0
grepconf () {
w=\" \" # space tab
sq=/etc/squid/squid.conf
# sed is cool.
res=`sed -ne '
s/^'$1'['\"$w\"']\+\([^'\"$w\"']\+\).*$/\1/p;
t end;
d;
:end q' < $sq`
[ -n \"$res\" ] || res=$2
echo \"$res\"
}
grepconf2 () {
w=\" \" # space tab
sq=/etc/squid/$NAME.conf
# sed is cool.
res=`sed -ne '
s/^'$1'['\"$w\"']\+[^'\"$w\"']\+['\"$w\"']\+\([^'\"$w\"']\+\).*$/\1/p;
t end;
d;
:end q' < $sq`
[ -n \"$res\" ] || res=$2
echo \"$res\"
}
#
# Try to increase the # of filedescriptors we can open.
#
maxfds () {
[ -n \"$SQUID_MAXFD\" ] || return
[ -f /proc/sys/fs/file-max ] || return 0
global_file_max=`cat /proc/sys/fs/file-max`
minimal_file_max=$(($SQUID_MAXFD + 4096))
if [ \"$global_file_max\" -lt $minimal_file_max ]
then
echo $minimal_file_max > /proc/sys/fs/file-max
fi
ulimit -n $SQUID_MAXFD
}
start () {
cdr=`grepconf2 cache_dir /var/spool/$NAME`
ctp=`grepconf cache_dir ufs`
case \"$cdr\" in
[0-9]*)
log_failure_msg \"squid: squid.conf contains 2.2.5 syntax - not starting!\"
log_end_msg 1
exit 1
;;
esac
#
# Create spool dirs if they don't exist.
#
if [ -d \"$cdr\" -a ! -d \"$cdr/00\" ] || [ \"$ctp\" = \"coss\" -a ! -f \"$cdr\" ]
then
log_warning_msg \"Creating squid cache structure\"
$DAEMON $SQUID_ARGS -z
fi
if [ \"$CHUID\" = \"\" ]; then
CHUID=root
fi
maxfds
umask 027
start-stop-daemon --quiet --start \
--pidfile $PIDFILE \
--chuid $CHUID \
--exec $DAEMON -- $SQUID_ARGS < /dev/null
return $?
}
stop () {
PID=`cat $PIDFILE 2>/dev/null`
start-stop-daemon --stop --quiet --pidfile $PIDFILE --name squid
#
# Now we have to wait until squid has _really_ stopped.
#
sleep 2
if test -n \"$PID\" && kill -0 $PID 2>/dev/null
then
log_action_begin_msg \" Waiting\"
cnt=0
while kill -0 $PID 2>/dev/null
do
cnt=`expr $cnt + 1`
if [ $cnt -gt 24 ]
then
log_action_end_msg 1
return 1
fi
sleep 5
log_action_cont_msg \"\"
done
log_action_end_msg 0
return 0
else
return 0
fi
}
case \"$1\" in
start)
log_daemon_msg \"Starting Squid HTTP proxy\" \"squid\"
if start ; then
log_end_msg $?
else
log_end_msg $?
fi
;;
stop)
log_daemon_msg \"Stopping Squid HTTP proxy\" \"squid\"
if stop ; then
log_end_msg $?
else
log_end_msg $?
fi
;;
reload|force-reload)
log_action_msg \"Reloading Squid configuration files\"
start-stop-daemon --stop --signal 1 \
--pidfile $PIDFILE --quiet --exec $DAEMON
log_action_end_msg 0
;;
restart)
log_daemon_msg \"Restarting Squid HTTP proxy\" \"squid\"
stop
if start ; then
log_end_msg $?
else
log_end_msg $?
fi
;;
*)
echo \"Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart}\"
exit 3
;;
esac
</code>
exit 0
28.
sudo chmod +x /etc/init.d/squid
29.
sudo update-rc.d squid defaults
Now, let’s configure.


Squid setup and configuration for a high-load environment…
IBM x335 server with 2 Xeon 2.4GHz CPUs, 2GB RAM, 2×36GB SCSI hard drives.
Note, that I will not use RAID, because I only have 2 hard drives and I need’em both for different roles to maximize performance. Plus, I have a cluster of squid servers, so …