Linux Squid installation and debugging several commonly used commands introduced

  

1, initialize the cache directory you configured in squid.conf

#squid/sbin/squid -z //The first time you start the Squid service You must enter this command

If there is an error, check the permissions of your cache directory.

2. Troubleshoot your squid.conf, verify the syntax and configuration of squid.conf.

#squid/sbin/squid -k parse

If squid.conf has syntax or configuration errors, it will return you here. If not, congratulations, you can try to start Squid.

3, start Squid in the foreground, and output the boot process.

#squid/sbin/squid -N -d1

If you have ready to server reques, congratulations, the startup is successful.

Then ctrl + c, stop Squid and start it in the background.

4, start squid running in the background.

#squid/sbin/squid -s

At this time, you can view the system process by ps -A, you can see two squid processes.

5, stop squid

#squid/sbin/squid -k shutdown

This is not to explain. //This article transferred from www.45it.com computer software and hardware application network

6, rebooted modified squid.conf

#squid/sbin/squid-k reconfigure

This estimate is used more often. When you find that your configuration is not what you want, you can modify Squid.conf at any time, and then don't forget to debug your Squid.conf, and then execute this command. Let the running squid run again in accordance with your squid.conf.

7. Add Squid to the system startup item

Edit /etc/rc.d/rc.local

Add the following line: /usr/local/squid/sbin /squid -s

Of course, not everyone likes this kind of startup, you can use the way you are most used to; or install it as a service.


A little more.

1. Modify the permissions of the cache cache directory.

#chown -R squid:squid /home/cache

My cache cache directory is /home/cache, Squid execution user and user group is squid, squid.

2, modify the squid log directory permissions

#chown -R squid:squid /usr/local/squid/var/logs

This step is not suitable for each Users who use Squid. It means that Squid has permission to write in this directory.

For example, generate access.log cache.log store.log

3, view your log file.

#more /usr/local/squid/var/logs/access.log |  Grep TCP_MEM_HIT

This command can see that during the Squid run, those files are cached in memory by Squid and returned to the accessing user.

#more /usr/local/squid/var/logs/access.log |  Grep TCP_HIT

This command can see that during the Squid run, those files are cached by Squid into the cache directory and returned to the access user.

#more /usr/local/squid/var/logs/access.log |  Grep TCP_MISS

This command can be seen that during the Squid running process, those files are not cached by Squid, but are now retrieved by the original server and returned to the accessing user.

For information on parameters such as TCP_XXXX and representative information, please refer to chapter 13.2.1 of www.chinaunix.org Peng Yonghua's "Squid Chinese Authoritative Guide".

Of course, the blue text in this example can be modified to other parameters, such as your domain name www.xxxx.com, you can also see the line in the access.log about the domain name.

4, Squid -k rotate Rotate Squid's log file /var/log/squid, Squid proxy server log file

The growth rate is amazing, it is easy to point the ball full of disk space The system does not work properly, or even crashes. In order to solve the problem that the log file grows too fast, Squid adopts the "rotation" method. In squid.conf, you can set the number of file rotations by logfile_rotate, such as:


logfile_rotate 10, the rotation work generally uses the crontab timer to complete the periodic log rotation, for example, log rotation every Saturday at 2:00 am, execute the following command: crontab -e


0 2 * * 6 squid -k rotate


Tip: Squid default error message is English, for users with bad English, it is inconvenient. In /etc Add the following in /squid/squid.conf:


error_directory /usr/share/squid/errors/Simplify_Chinese You can display the Chinese error message.

Copyright © Windows knowledge All Rights Reserved