nginx+apache+mysql+php+memcached+squid´î½¨¼¯Èºweb»·¾³
Ò»¡¢Ç°ÑÔ
¶þ¡¢±àÒë°²×°
Èý¡¢ °²×°MySQL¡¢memcache
ËÄ¡¢ °²×°Apache¡¢PHP¡¢eAccelerator¡¢php-memcache
Îå¡¢ °²×°Squid
Áù¡¢ºó¼Ç
Ò»¡¢Ç°ÑÔ£¬×¼±¸¹¤×÷
µ±Ç°£¬LAMP¿ª·¢Ä£Ê½ÊÇWEB¿ª·¢µÄÊ×Ñ¡£¬ÈçºÎ´î½¨Ò»¸ö¸ßЧ¡¢¿É¿¿¡¢Îȶ¨µÄWEB·þÎñÆ÷Ò»Ö±ÊǸöÈÈÃÅÖ÷Ì⣬±¾ÎľÍÊÇÕâ¸öÖ÷ÌâµÄÒ»´Î³¢ÊÔ¡£
ÎÒÃDzÉÓõļܹ¹Í¼ÈçÏ£º
ÒýÓÃ-------- ---------- ------------- --------- ------------
| ¿Í»§¶Ë | ===> |¸ºÔؾùºâÆ÷| ===> |·´Ïò´úÀí/»º´æ| ===> |WEB·þÎñÆ÷| ===> |Êý¾Ý¿â·þÎñÆ÷|
-------- ---------- ------------- --------- ------------
Nginx Squid Apache,PHP MySQL
eAccelerator/memcache×¼±¸¹¤×÷£º
ÒýÓ÷þÎñÆ÷£º Intel(R) Xeon(TM) CPU 3.00GHz * 2, 2GB mem, SCISC Ó²ÅÌ
²Ù×÷ϵͳ£ºCentOs4.4£¬Äں˰汾2.6.9-22.ELsmp£¬gcc°æ±¾3.4.4
Èí¼þ£º
Apache 2.2.3£¨ÄÜʹÓÃMPMģʽ£©
PHP 5.2.0£¨Ñ¡Óøð汾ÊÇÒòΪ5.2.0µÄÒýÇæÏà¶Ô¸ü¸ßЧ£©
eAccelerator 0.9.5£¨¼ÓËÙPHPÒýÇ棬ͬʱҲ¿ÉÒÔ¼ÓÃÜPHPÔ´³ÌÐò£©
memcache 1.2.0£¨ÓÃÓÚ¸ßËÙ»º´æ³£ÓÃÊý¾Ý£©
libevent 1.2a£¨memcache¹¤×÷»úÖÆËùÐ裩
MySQL 5.0.27£¨Ñ¡Óöþ½øÖÆ°æ±¾£¬Ê¡È¥±àÒ빤×÷£©
Nginx 0.5.4£¨ÓÃ×ö¸ºÔؾùºâÆ÷£©
squid-2.6.STABLE6£¨×ö·´Ïò´úÀíµÄͬʱÌṩרҵ»º´æ¹¦ÄÜ£©
¶þ¡¢±àÒë°²×°
Ò»¡¢) °²×°Nginx
1.) °²×°
Nginx·¢ÒôΪ[engine x]£¬ÊÇÓɶíÂÞ˹ÈËIgor Sysoev½¨Á¢µÄÏîÄ¿,»ùÓÚBSDÐí¿É¡£¾Ý˵Ëûµ±³õÊÇF5µÄ³ÉÔ±Ö®Ò»£¬Ó¢ÎÄÖ÷Ò³£ºhttp://nginx.net¡£¶íÂÞ˹µÄһЩ´óÍøÕ¾ÒѾʹÓÃËü³¬¹ýÁ½Äê¶àÁË£¬Ò»Ö±±íÏÖ²»·²¡£
NginxµÄ±àÒë²ÎÊýÈçÏ£º
[root@localhost]#./configure --prefix=/usr/local/server/nginx --with-openssl=/usr/include \
--with-pcre=/usr/include/pcre/ --with-http_stub_status_module --without-http_memcached_module \
--without-http_fastcgi_module --without-http_rewrite_module --without-http_map_module \
--without-http_geo_module --without-http_autoindex_module
ÔÚÕâÀÐèҪ˵Ã÷һϣ¬ÓÉÓÚNginxµÄÅäÖÃÎļþÖÐÎÒÏëÓõ½ÕýÔò£¬ËùÒÔÐèÒª pcre Ä£¿éµÄÖ§³Ö¡£ÎÒÒѾ°²×°ÁË pcre ¼° pcre-devel µÄrpm°ü£¬µ«ÊÇ Ngxin ²¢²»ÄÜÕýÈ·ÕÒµ½ .h/.so/.a/.la Îļþ£¬Òò´ËÎÒÉÔ΢±äͨÁËһϣº
[root@localhost]#mkdir /usr/include/pcre/.libs/
[root@localhost]#cp /usr/lib/libpcre.a /usr/include/pcre/.libs/libpcre.a
[root@localhost]#cp /usr/lib/libpcre.a /usr/include/pcre/.libs/libpcre.la
È»ºó£¬ÐÞ¸Ä objs/Makefile ´ó¸ÅÔÚ908ÐеÄλÖÃÉÏ£¬×¢Ê͵ôÒÔÏÂÄÚÈÝ£º
./configure --disable-shared
½ÓÏÂÀ´£¬¾Í¿ÉÒÔÕý³£Ö´ÐÐ make ¼° make install ÁË¡£
2.) ÐÞ¸ÄÅäÖÃÎļþ /usr/local/server/nginx/conf/nginx.conf
ÒÔÏÂÊÇÎÒµÄ nginx.conf ÄÚÈÝ£¬½ö¹©²Î¿¼£º
#ÔËÐÐÓû§
user nobody nobody;
#Æô¶¯½ø³Ì
worker_processes 2;
#È«¾Ö´íÎóÈÕÖ¾¼°PIDÎļþ
error_log logs/error.log notice;
pid logs/nginx.pid;
#¹¤×÷ģʽ¼°Á¬½ÓÊýÉÏÏÞ
events {
use epoll;
worker_connections 1024;
}
#É趨http·þÎñÆ÷£¬ÀûÓÃËüµÄ·´Ïò´úÀí¹¦ÄÜÌṩ¸ºÔؾùºâÖ§³Ö
http {
#É趨mimeÀàÐÍ
include conf/mime.types;
default_type application/octet-stream;
#É趨ÈÕÖ¾¸ñʽ
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
log_format download '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_range" "$sent_http_content_range"';
#É趨ÇëÇ󻺳å
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
#¿ªÆôgzipÄ£¿é
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
#É趨access log
access_log logs/access.log main;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
#É趨¸ºÔؾùºâµÄ·þÎñÆ÷Áбí
upstream mysvr {
#weigth²ÎÊý±íʾȨֵ£¬È¨ÖµÔ½¸ß±»·ÖÅäµ½µÄ¼¸ÂÊÔ½´ó
#±¾»úÉϵÄSquid¿ªÆô3128¶Ë¿Ú
server 192.168.8.1:3128 weight=5;
server 192.168.8.2:80 weight=1;
server 192.168.8.3:80 weight=6;
}
#É趨ÐéÄâÖ÷»ú
server {
listen 80;
server_name 192.168.8.1 www.360mini.com;
charset gb2312;
#É趨±¾ÐéÄâÖ÷»úµÄ·ÃÎÊÈÕÖ¾
access_log logs/www.360mini.com.access.log main;
#Èç¹û·ÃÎÊ /img/*, /js/*, /css/* ×ÊÔ´£¬ÔòÖ±½ÓÈ¡±¾µØÎļþ£¬²»Í¨¹ýsquid
#Èç¹ûÕâЩÎļþ½Ï¶à£¬²»ÍƼöÕâÖÖ·½Ê½£¬ÒòΪͨ¹ýsquidµÄ»º´æЧ¹û¸üºÃ
location ~ ^/(img|js|css)/ {
root /data3/Html;
expires 24h;
}
#¶Ô "/" ÆôÓøºÔؾùºâ
location / {
proxy_pass http://mysvr;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
#É趨²é¿´Nginx״̬µÄµØÖ·
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
auth_basic_user_file conf/htpasswd;
}
}
}
±¸×¢£ºconf/htpasswd ÎļþµÄÄÚÈÝÓà apache ÌṩµÄ htpasswd ¹¤¾ßÀ´²úÉú¼´¿É£¬ÄÚÈÝ´óÖÂÈçÏ£º
3.) ²é¿´ Nginx ÔËÐÐ״̬
ÊäÈëµØÖ· http://192.168.8.1/NginxStatus/£¬ÊäÈëÑéÖ¤ÕʺÅÃÜÂ룬¼´¿É¿´µ½ÀàËÆÈçÏÂÄÚÈÝ£º
Active connections: 328
server accepts handled requests
9309 8982 28890
Reading: 1 Writing: 3 Waiting: 324
µÚÒ»ÐбíʾĿǰ»îÔ¾µÄÁ¬½ÓÊý
µÚÈýÐеĵÚÈý¸öÊý×Ö±íʾNginxÔËÐе½µ±Ç°Ê±¼ä½ÓÊܵ½µÄ×ÜÇëÇóÊý£¬Èç¹û¿ì´ïµ½ÁËÉÏÏÞ£¬¾ÍÐèÒª¼Ó´óÉÏÏÞÖµÁË¡£
µÚËÄÐÐÊÇNginxµÄ¶ÓÁÐ״̬
Èý¡¢ °²×°MySQL¡¢memcache
1.) °²×°MySQL£¬²½ÖèÈçÏ£º
[root@localhost]#tar zxf mysql-standard-5.0.27-linux-i686.tar.gz -C /usr/local/server
[root@localhost]#mv /usr/local/server/mysql-standard-5.0.27-linux-i686 /usr/local/server/mysql
[root@localhost]#cd /usr/local/server/mysql
[root@localhost]#./scripts/mysql_install_db --basedir=/usr/local/server/mysql \
--datadir=/usr/local/server/mysql/data --user=nobody
[root@localhost]#cp /usr/local/server/mysql/support-files/my-large.cnf \
/usr/local/server/mysql/data/my.cnf
2.) ÐÞ¸Ä MySQL ÅäÖã¬Ôö¼Ó²¿·ÖÓÅ»¯²ÎÊý£¬ÈçÏ£º
[root@localhost]#vi /usr/local/server/mysql/data/my.cnf
Ö÷ÒªÄÚÈÝÈçÏ£º
[mysqld]
basedir = /usr/local/server/mysql
datadir = /usr/local/server/mysql/data
user = nobody
port = 3306
socket = /tmp/mysql.sock
wait_timeout = 30
long_query_time=1
#log-queries-not-using-indexes = TRUE
log-slow-queries=/usr/local/server/mysql/slow.log
log-error = /usr/local/server/mysql/error.log
external-locking = FALSE
key_buffer_size = 512M
back_log = 400
table_cache = 512
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 32
query_cache_limit = 2M
query_cache_size = 64M
thread_concurrency = 4
thread_stack = 128K
tmp_table_size = 64M
binlog_cache_size = 2M
max_binlog_size = 128M
max_binlog_cache_size = 512M
max_relay_log_size = 128M
bulk_insert_buffer_size = 8M
myisam_repair_threads = 1
skip-bdb
#Èç¹û²»ÐèҪʹÓÃinnodb¾Í¹Ø±Õ¸ÃÑ¡Ïî
#skip-innodb
innodb_data_home_dir = /usr/local/server/mysql/data/
innodb_data_file_path = ibdata1:256M;ibdata2:256M:autoextend
innodb_log_group_home_dir = /usr/local/server/mysql/data/
innodb_log_arch_dir = /usr/local/server/mysql/data/
innodb_buffer_pool_size = 512M
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 128M
innodb_log_buffer_size = 8M
innodb_lock_wait_timeout = 50
innodb_flush_log_at_trx_commit = 2
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_log_files_in_group = 3
ÒÔÉÏÅäÖòÎÊýÇë¸ù¾Ý¾ßÌåµÄÐèÒªÉÔ×÷Ð޸ġ£ÔËÐÐÒÔÏÂÃüÁî¼´¿ÉÆô¶¯ MySQL ·þÎñÆ÷£º
/usr/local/server/mysql/bin/mysqld_safe \
--defaults-file=/usr/local/server/mysql/data/my.cnf &
ÓÉÓÚ MySQL ²»ÊÇ°²×°ÔÚ±ê׼Ŀ¼Ï£¬Òò´Ë±ØÐëÒªÐÞ¸Ä mysqld_safe ÖÐµÄ my_print_defaults ÎļþËùÔÚλÖ㬲ÅÄÜͨ¹ý
mysqld_safe À´Æô¶¯ MySQL ·þÎñÆ÷¡£
3.) memcache + libevent °²×°±àÒë°²×°£º
[root@localhost]#cd libevent-1.2a
[root@localhost]#./configure --prefix=/usr/ && make && make install
[root@localhost]#cd ../memcached-1.2.0
[root@localhost]#./configure --prefix=/usr/local/server/memcached --with-libevent=/usr/
[root@localhost]#make && make install
±¸×¢£ºÈç¹û libevent ²»ÊÇ°²×°ÔÚ /usr Ŀ¼Ï£¬ÄÇôÐèÒª°Ñ libevent-1.2a.so.1 ¿½±´/Á´½Óµ½ /usr/lib ÖУ¬·ñÔò
memcached ÎÞ·¨Õý³£¼ÓÔØ¡£ÔËÐÐÒÔÏÂÃüÁîÀ´Æô¶¯ memcached£º
[root@localhost]#/usr/local/server/memcached/bin/memcached \
-l 192.168.8.1 -d -p 10000 -u nobody -m 128
±íʾÓà daemon µÄ·½Ê½Æô¶¯ memcached£¬¼àÌýÔÚ 192.168.8.1 µÄ 10000 ¶Ë¿ÚÉÏ£¬ÔËÐÐÓû§Îª nobody£¬ÎªÆä·ÖÅä
128MB µÄÄÚ´æ¡£
ËÄ¡¢ °²×°Apache¡¢PHP¡¢eAccelerator¡¢php-memcache
ËÄ¡¢) °²×°Apache¡¢PHP¡¢eAccelerator¡¢php-memcacheÓÉÓÚApache
2ϵÄphp¾²Ì¬·½Ê½±àÒëÊ®·ÖÂé·³£¬Òò´ËÔÚÕâÀï²ÉÓö¯Ì¬Ä£¿é(DSO)·½Ê½¡£1.) °²×°Apache 2.2.3
[root@localhost]#./configure --prefix=/usr/local/server/apache --disable-userdir --disable-actions \
--disable-negotiation --disable-autoindex --disable-filter --disable-include --disable-status \
--disable-asis --disable-auth --disable-authn-default --disable-authn-file --disable-authz-groupfile \
--disable-authz-host --disable-authz-default --disable-authz-user --disable-userdir \
--enable-expires --enable-module=so
±¸×¢£ºÔÚÕâÀȡÏûÁËһЩ²»±ØÒªµÄÄ£¿é£¬Èç¹ûÄãÐèÒªÓõ½ÕâЩģ¿é£¬ÄÇôÇëÈ¥µô²¿·Ö²ÎÊý¡£
2.) °²×°PHP 5.2.0
[root@localhost]#./configure --prefix=/usr/local/server/php --with-mysql \
--with-apxs2=/usr/local/server/apache/bin/apxs --with-freetype-dir=/usr/ --with-png-dir=/usr/ \
--with-gd=/usr/ --with-jpeg-dir=/usr/ --with-zlib --enable-magic-quotes --with-iconv \
--without-sqlite --without-pdo-sqlite --with-pdo-mysql --disable-dom --disable-simplexml \
--enable-roxen-zts
[root@localhost]#make && make install
±¸×¢£ºÈç¹û²»ÐèÒªgd»òÕßpdoµÈÄ£¿é£¬Çë×ÔÐÐÈ¥µô¡£
3.) °²×°eAccelerator-0.9.5
[root@localhost]#cd eAccelerator-0.9.5
[root@localhost]#export PHP_PREFIX=/usr/local/server/php
[root@localhost]#$PHP_PREFIX/bin/phpize
[root@localhost]#./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
[root@localhost]#make && make install
4.) °²×°memcacheÄ£¿é
[root@localhost]#cd memcache-2.1.0
[root@localhost]#export PHP_PREFIX=/usr/local/server/php
[root@localhost]#$PHP_PREFIX/bin/phpize
[root@localhost]#./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
[root@localhost]#make && make install
5.) ÐÞ¸Ä php.ini ÅäÖÃÈ»ºóÐÞ¸Ä php.ini£¬ÐÞ¸Ä/¼ÓÈëÀàËÆÒÔÏÂÄÚÈÝ£º
extension_dir = "/usr/local/server/php/lib/"
extension="eaccelerator.so"
eaccelerator.shm_size="32" ;É趨eacceleratorµÄ¹²ÏíÄÚ´æΪ32MB
eaccelerator.cache_dir="/usr/local/server/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter="*.php"
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.log_file = "/usr/local/server/apache/logs/eaccelerator_log"
eaccelerator.allowed_admin_path = "/usr/local/server/apache/htdocs/ea_admin"
extension="memcache.so"
ÔÚÕâÀ×îºÃÊÇÔÚapacheµÄÅäÖÃÖÐÔö¼ÓĬÈÏÎļþÀàÐ͵Äcache»úÖÆ£¬¼´ÀûÓÃapacheµÄexpiresÄ£¿é£¬ÐÂÔöÀàËÆÈçϼ¸ÐУº
ExpiresActive On
ExpiresByType text/html "access plus 10 minutes"
ExpiresByType text/css "access plus 1 day"
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/jpg "access 1 month"
ExpiresByType application/x-shockwave-flash "access plus 3 day"
ÕâôÉèÖÃÊÇÓÉÓÚÎÒµÄÕâЩ¾²Ì¬Îļþͨ³£ºÜÉÙ¸üУ¬Òò´ËÎÒÑ¡ÔñµÄÊÇ"access"¹æÔò£¬Èç¹û¸üÐÂÏà¶Ô±È½ÏƵ·±£¬¿ÉÒÔ¸ÄÓÃ"modification"¹æÔò;»òÕßÒ²¿ÉÒÔÓÃ"access"¹æÔò£¬µ«ÊÇÔÚÎļþ¸üеÄʱºò£¬Ö´ÐÐÒ»ÏÂ"touch"ÃüÁ°ÑÎļþµÄʱ¼äË¢ÐÂһϼ´¿É¡£
Îå¡¢ °²×°Squid
Îå¡¢) °²×°Squid
[root@localhost]#./configure --prefix=/usr/local/server/squid --enable-async-io=100 --disable-delay-pools --disable-mem-gen-trace --disable-useragent-log --enable-kill-parent-hack --disable-arp-acl --enable-epoll --disable-ident-lookups --enable-snmp --enable-large-cache-files --with-large-files
[root@localhost]#make && make install
»òʹÓÃÈçÏ°²×°·½·¨£º
[root@localhost]#yum install squid
Èç¹ûÊÇ2.6µÄÄںˣ¬²ÅÄÜÖ§³ÖepollµÄIOģʽ£¬¾É°æ±¾µÄÄÚºËÔòÖ»ÄÜÑ¡Ôñpoll»òÆäËûģʽÁË;ÁíÍ⣬¼ÇµÃ´øÉÏÖ§³Ö´óÎļþµÄÑ¡Ï·ñÔòÔÚaccess
logµÈÎļþ´ïµ½2GµÄʱºò¾Í»á±¨´í¡£É趨 squid µÄÅäÖôó¸ÅÈçÏÂÄÚÈÝ£º
#É趨»º´æĿ¼Ϊ /var/cache1 ºÍ /var/lib/squid£¬Ã¿´Î´¦Àí»º´æ´óСΪ128MB£¬µ±»º´æ¿Õ¼äʹÓôﵽ95%ʱ
#еÄÄÚÈݽ«È¡´ú¾ÉµÄ¶ø²»Ö±½ÓÌí¼Óµ½Ä¿Â¼ÖУ¬Ö±µ½¿Õ¼äÓÖϽµµ½90%²ÅÍ£Ö¹ÕâÒ»»î¶¯
#/var/cache1 ×î´ó1024MB£¬/var/lib/squid ×î´ó 5000MB£¬¶¼ÊÇ 16*256 ¼¶×ÓĿ¼
cache_dir aufs /var/cache1 1024 16 256
cache_dir aufs /var/lib/squid 5000 16 256
cache_mem 128 MB
cache_swap_low 90
cache_swap_high 95
#ÉèÖô洢²ßÂÔµÈ
maximum_object_size 4096 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 80 KB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
cache_replacement_policy lru
memory_replacement_policy lru
#ÉèÖó¬Ê±²ßÂÔ
forward_timeout 20 seconds
connect_timeout 15 seconds
read_timeout 3 minutes
request_timeout 1 minutes
persistent_request_timeout 15 seconds
client_lifetime 15 minutes
shutdown_lifetime 5 seconds
negative_ttl 10 seconds
#ÏÞÖÆÒ»¸öip×î´óÖ»ÄÜÓÐ16¸öÁ¬½Ó
acl OverConnLimit maxconn 16
http_access deny OverConnLimit
#ÏÞÖÆbaidu spider·ÃÎÊ
#acl AntiBaidu req_header User-Agent Baiduspider
#http_access deny AntiBaidu
#³£¹æÉèÖÃ
visible_hostname cache.yejr.com
cache_mgr 1638651355@qq.com client_persistent_connections off
server_persistent_connections on
cache_effective_user nobody
cache_effective_group nobody
tcp_recv_bufsize 65535 bytes
half_closed_clients off
#É趨²»»º´æµÄ¹æÔò
hierarchy_stoplist cgi-bin
acl QUERY urlpath_regex cgi-bin
cache deny QUERY
#²»ÒªÏàÐÅETag ÒòΪÓÐgzip
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
#ÉèÖÃaccess log£¬²¢ÇÒÁîÆä¸ñʽºÍapacheµÄ¸ñʽһÑù£¬·½±ãawstats·ÖÎö
emulate_httpd_log on
logformat apache %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %
³õʼ»¯ºÍÆô¶¯squid
[root@localhost]#/usr/local/server/squid/sbin/squid -z
[root@localhost]#/usr/local/server/squid/sbin/squid
µÚÒ»ÌõÃüÁîÊÇÏȳõʼ»¯squid»º´æ¹þÏ£×ÓĿ¼£¬Ö»ÐèÖ´ÐÐÒ»´Î¼´¿É¡£
Áù¡¢ºó¼Ç
Áù¡¢ºó¼ÇÒ»¡¢)ÏëÒªÆôÓÃsquidËùÐèµÄ¸Ä±äÏëÒª¸üºÃµÄÀûÓÃsquidµÄcache¹¦ÄÜ£¬²»ÊÇ°ÑËüÆôÓÃÁ˾ͿÉÒԵģ¬ÎÒÃÇÐèÒª×öÒÔϼ¸¸öµ÷Õû£º
1¡¢ÆôÓÃapacheµÄ mod_expires Ä£¿é£¬ÐÞ¸Ä httpd.conf£¬¼ÓÈëÒÔÏÂÄÚÈÝ£º
#expiresdefault "modification plus 2 weeks"expiresactive
onexpiresbytype text/html "access plus 10 minutes"expiresbytype
image/gif "modification plus 1 month"expiresbytype image/jpeg "modification
plus 1 month"expiresbytype image/png "modification plus 1
month"expiresbytype text/css "access plus 1 day"expiresbytype
application/x-shockwave-flash "access plus 3 day"
ÒÔÉÏÅäÖõÄ×÷ÓÃÊǹ涨¸÷ÖÖÀàÐÍÎļþµÄcache¹æÔò£¬¶ÔÄÇЩͼƬ/flashµÈ¾²Ì¬Îļþ×ÜÊÇcacheÆðÀ´£¬¿É¸ù¾Ý¸÷×ÔµÄÐèÒª×öÊʵ±µ÷Õû¡£
2¡¢ÐÞ¸Ä php.ini ÅäÖã¬ÈçÏ£º
session.cache_limiter = nocache
ÒÔÉÏÅäÖõÄ×÷ÓÃÊÇĬÈÏÈ¡ÏûphpÖеÄcache¹¦ÄÜ£¬±ÜÃâ²»Õý³£µÄcache²úÉú¡£
3¡¢ÐÞ¸ÄÓ¦ÓóÌÐòÀýÈ磬ÓÐÒ»¸öphp³ÌÐòÒ³Ãæstatic.php£¬Ëü´æ·Å×ÅijЩ²éѯÊý¾Ý¿âºóµÄ½á¹û£¬²¢ÇÒÊý¾Ý¸üв¢²»Æµ·±£¬ÓÚÊÇ£¬ÎÒÃǾͿÉÒÔ¿¼ÂǶÔÆäcache¡£Ö»ÐèÔÚstatic.phpÖмÓÈëÀàËÆÈçÏ´úÂ룺
header('Cache-Control: max-age=86400
,must-revalidate');header('Pragma:');header('Last-Modified: ' .
gmdate('D, d M Y H:i:s') . ' GMT' );header("Expires: " .gmdate ('D, d M Y
H:i:s', time() + '86400' ). ' GMT');
ÒÔÉÏ´úÂëµÄÒâ˼ÊÇ£¬Êä³öÒ»¸öhttpÍ·²¿ÐÅÏ¢£¬ÈÃsquidÖªµÀ±¾Ò³ÃæĬÈÏ»º´æʱ³¤ÎªÒ»Ìì¡£
¶þ¡¢)squidclient¼òÒª½éÉÜ
*È¡µÃsquidÔËÐÐ״̬ÐÅÏ¢£º squidclient -p 80 mgr:info
*È¡µÃsquidÄÚ´æʹÓÃÇé¿ö£º squidclient -p 80 mgr:mem
*È¡µÃsquidÒѾ»º´æµÄÁÐ±í£º squidclient -p 80 mgr:objects. use it carefully,it may crash
*È¡µÃsquidµÄ´ÅÅÌʹÓÃÇé¿ö£º squidclient -p 80 mgr:diskd
*Ç¿ÖƸüÐÂij¸öurl£ºsquidclient -p 80 -m PURGE http://www.360mini.com/static.php
*¸ü¶àµÄÇë²é¿´£ºsquidclient-h »òÕß squidclient -p 80 mgr:
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ