Accelerate apache with squid

Source: Internet
Author: User
Descriwgetlabs. xiaonei. comapach

Apache (Port 81) squid (port 80) (reverse proxy must be implemented for apache and squid running on the same machine) I replaced my internet domain with zhlinux.com to download 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 (Port 81) squid (port 80) (apache and squid run on the same machine to implement reverse proxy) I replaced my Internet domain name with zhlinux.com

Download 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

Install apache

Tar zxvf httpd-2.2.14.tar.gz

Cd httpd-2.2.14

./Configure -- prefix =/usr/local/apache2

Make & make install

You can configure parameters according to your needs.

The apache configuration is as follows:
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

Start apache
View listening port

Netstat-ntpl | grep 81

Install 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

Configure the squid. conf file

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_inclutive_user squid
Cache_paitive_group squid

Verify that squid. conf is correctly configured.
/Usr/local/squid/sbin/squid-k parse

If no problem exists
/Usr/local/squid/etc/squid. conf (depth 0)

/Usr/local/squid/sbin/squid-z
Used to Creating Swap Directories

Create squid Startup Script

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
Grant execution permission

Chmod x squid. sh

./Squid. sh start

Check whether startup is enabled
# Ps fax | grep squid
13750 pts/3 S \ _ grep squid
30474? Ss 0: 00/usr/local/squid/sbin/squid-s
30476? S 0: 01 \ _ (squid)-s
It proves OK

More/usr/local/squid/var/logs/page_zs_access_log | grep TCP_MEM_HIT
This command shows that during squid running, some files are cached into the memory by squid and returned to the access user.

More/usr/local/squid/var/logs/page_zs_access_log | grep TCP_HIT
This command shows that some files are cached by squid into the cache directory during squid operation and returned to the access user.

You can view the hit rate and other related information.
#/Usr/local/squid/bin/squidclient-p 80-h localhost mgr: info

Note: This document is based on some documents on the network.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.