Install and configure squid

Source: Internet
Author: User
Tags dedicated server
As the most popular operating system, Linux has become increasingly popular. Although Linux software is not rich yet,
It is too early to replace windows as an ordinary PC operating system. However, in the server field, Linux is always stable and operable.
And has excellent software support. Squid is one of them. Linux and squid combination as proxy
The server has far higher performance than WINNT and msproxy2.0 (personal opinion). It is more than enough for a small LAN proxy of several hundred people. Lower
I will introduce the installation and usage of squid in detail. I hope you will like it.

1. Squid Introduction

Squid is a software used to cache Internet data. It receives user download requests and automatically processes the downloaded data.
That is to say, when a user wants to download a home page, it sends an application to squid, needs squid to download it for it, and then squid
Connect to the requested website and request the Home Page. Then, the home page is sent to the user and a backup is retained. When other users apply for the same page
Squid immediately transmits the saved backup to the user, making the user feel that the speed is quite fast. Currently, squid can proxy HTTP, FTP,
Gopher, SSL, and WAIS protocols. Currently, they cannot proxy protocols such as pop and nntp. However, someone has begun modifying squid.
For a long time, squid will be able to proxy these protocols.

Can Squid cache any data? No. Like cached credit card accounts, scripts that can be executed remotely, frequently changed
Homepage is inappropriate and insecure. Squid can be automatically processed. You can also set squid as needed,
To filter out what you don't want.

Squid can work in many operating systems, such as Aix, Digital UNIX, FreeBSD, HP-UX, Irix, Linux,
NetBSD, nextstep, SCO, Solaris, OS/2, and many others recompile squid in other operating systems.

Squid's requirement for hardware is that the memory must be large and should not be less than 128 M. The faster the hard disk speed, the better. It is best to use dedicated server SCSI.
Hard Disk, processor requirements are not high, more than MH can be.

2. Squid compilation and running

In fact, the current Linux release kit basically has compiled squid. What you do is to install it. If you have
If you do not have a compiled squid or want to use the latest version, download it from ftp: squid.nlanr.net and compile it by yourself.

Squid compilation is very simple, because it basically configures itself. The most common problem is that your system does not
Suitable compiler, which can be solved by installing the appropriate compiler. If you have other questions, you can ask experienced users or
Go to the corresponding email list to find help.

Before compiling squid, it is best to create a user and group dedicated to running squid. I created
Squid user and group. The user directory is set to/usr/local/squid. Then Su downloads the squid from squid.nlanr.net.
To the/usr/local/squid/src directory, run the following command to decompress the squid source file:

% Tar xzf squid-2.0.RELEASE-src.tar.gz

% Cd/usr/local/squid/src/squid-*. *. Release/

%./Configure

% Make

% Make install

The first command generates a new subdirectory/squid-*. *. Release/in the directory/usr/local/squid/src /. Command
./Configure will automatically query your system configuration and the header files used in your system. ./Configure without parameters will
Install squid in the/usr/local/squid directory. If you want to use another directory, run the following command:
./Configure -- prefix =/Some/other/directory. This will install squid in the/Some/other/directory.
Make command to compile squid, make install command to install squid.

The following directory appears in the directory/usr/local/squid:

/Bin

/Cache

/Etc

/Logs/

/Src (self-created)

The directory/bin contains squid executableProgramIncluding squid itself and ftpget.

Directory/cache contains squid cached data, including directories such as/00/01/02/AND/03/. These directories
There are also subdirectories in the directory, because it is easier and faster to search for a file from thousands of files in a directory.

The/etc directory contains the unique configuration file squid. conf of squid.

The/logs directory contains squid logs.

3. Configure the squid. conf file

After squid is installed, a sample squid. conf file is automatically generated in the/usr/local/squid/etc directory.
Each option is described in detail. You can modify the file to meet different needs.

In general, there are several important options:

· HTTP _ port: Set the port of the squid listener. You 'd better set a memorable port number for client configuration.
Easy to remember. The port number on my machine is 8080. The default value is 3128.

· Cache _ mem: Set the physical memory occupied by squid. Based on my experience, the size of cache_mem should not exceed your service.
1/3 of the physical memory of the machine. Otherwise, the overall performance of the machine will be affected.

· Maximum _ object_size: set the maximum object size that squid can receive. The default value of squid is 4 m.
If you think it is too big, you can set it based on your own needs.

· Cache _ DIR: Set the cache location and size. The general format is as follows:
"Cache_dir/usr/local/squid/cache 100 16 256 ". /Usr/local/squid/cache indicates the cache location;
100 represents the maximum cache size of 100 MB; 16 and 256 represent the number of level-1 and level-2 directories.

· Cache _ effective_user: Set the valid users who use the cache. The default value is user nobody.
If there is a user nobody, it is best to create one or run squid as a non-root user.

Below is a simple squid. conf file:

# Squid. conf-a very basic config file for squid

# Turn logging to it's lowest level

Debug_options all, 1

# Defines a group (or access control list) that includes des all IP addresses

ACL all SRC 0.0.0.0/0.0.0.0

# Define RAM used

Cache_mem 32 m

# Defines the cache size

Cache_dir/usr/local/squid/cache 100 16 256

# Allow all sites to use connect to us via HTTP

Http_access allow all

# Allow all sites to use us as a sibling

Icp_access allow all

# Test the following sites to check that we are connected

Dns_testnames internic.net usc.edu cs.colorado.edu mit.edu yale.edu

# Run as the squid user

Cache_inclutive_user squid

This configuration file allows everyone to use squid, create a m cache, use 32 M memory, in the default location
"/Usr/local/squid/cache" cached data. All cached data is saved as a group squid and user squid. The port is 3128.
Although this configuration is not safe, it can be used.

4. Run squid

First, log in as root. Run the following command:

%/Usr/local/squid/bin/squid-z

This command will generate all the cache directories of squid.

If you want to run squid on the front-end, run the following command:

%/Usr/local/squid/bin/squid-ncd1

This command officially starts squid. If everything is normal, you will see a line of output

Ready to serve requests.

If you want to run squid in the background and use it as an genie process, run the following command:

%/Usr/local/squid/bin/squid

Check whether squid runs the command:

% Squid-K check

The output will tell you the current status of squid.

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.