ÔõÑùͨ¹ý¸¡Í¼Ãæ°å¾ÙÐÐApacheЧÀÍÆ÷µÄÐÔÄÜÓÅ»¯
Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤£¬ÍøÕ¾µÄ»á¼ûËÙÂÊÒѳÉΪӰÏìÓû§ÌåÑéºÍseoÅÅÃûµÄÖ÷ÒªÒòËØÖ®Ò»¡£¶øapache×÷Ϊ×îÊ¢ÐеÄwebЧÀÍÆ÷Ö®Ò»£¬ÆäÐÔÄÜÓÅ»¯Ò²ÏÔµÃÔ½À´Ô½Ö÷Òª¡£±¾ÎĽ«Îª¸÷ÈËÏÈÈÝÔõÑùͨ¹ý¸¡Í¼Ãæ°å¾ÙÐÐapacheЧÀÍÆ÷µÄÐÔÄÜÓÅ»¯¡£
Ò»¡¢ÉèÖÃApache»ù´¡ÉèÖÃ
Ê×ÏÈ£¬ÎÒÃÇÐèÒª·¿ª¸¡Í¼Ãæ°å²¢µÇ¼µ½Ö÷»ú£¬Ñ¡ÔñÍøÕ¾ÖÎÀí²¢½øÈëÐèÒªÓÅ»¯µÄÍøÕ¾£¬È»ºóÔÚÍøÕ¾ÉèÖÃÒ³ÃæÖÐÑ¡Ôñ¡°Apache¡±Ñ¡Ï¡£ÔÚ´Ë´¦£¬ÎÒÃÇ¿ÉÒÔƾ֤ÍøÕ¾µÄËùÐè¾ÙÐлù´¡ÉèÖõ÷½â£¬°üÀ¨¿ªÆôGzipѹËõ¡¢¹Ø±ÕEtagµÈ¡£
¶þ¡¢¿ªÆô»º´æÉèÖÃ
»º´æÊÇÌá¸ßÍøÕ¾»á¼ûËÙÂʵÄÓÐÓÃÒªÁìÖ®Ò»¡£ÔÚApacheЧÀÍÆ÷ÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÐÞ¸ÄÉèÖÃÎļþ¿ªÆô»º´æ¡£ÔÚ¸¡Í¼Ãæ°åÖУ¬ÎÒÃÇ¿ÉÒÔÑ¡Ôñ¡°ÎļþÖÎÀíÆ÷¡±£¬ÕÒµ½ÍøÕ¾µÄÉèÖÃÎļþ£¨Í¨³£Î»ÓÚ/etc/httpd/conf/httpd.conf»ò/etc/httpd/conf.d/Ŀ¼Ï£©²¢¾ÙÐÐÐ޸ġ£
ÒÔÏÂÊÇһЩ¿ªÆô»º´æµÄ³£ÓÃÑ¡Ï
1.ʹÓÃmod_cacheÄ£¿é¿ªÆôÄڴ滺´æ£º
LoadModule cache_module modules/mod_cache.so
LoadModule cache_socache_module modules/mod_socache_shmcb.so
LoadModule cache_disk_module modules/mod_cache_disk.so
CacheEnable mem /
CacheSocache shmcb:/tmp/cache (cache size 128M, 53M of 83M used)
LimitRequestBody 4096
CacheDefaultExpire 600
CacheEnable disk
CacheHeader on
CacheIgnoreHeaders Set-Cookie
CacheIgnoreNoLastMod On
CacheLastModifiedFactor 0.5
CacheLock on
CacheMinFileSize 1
CacheReadSize 4096
CacheStoreExpired off
CacheStoreNoStore off
2.ʹÓÃmod_expiresÄ£¿éÉèÖÃä¯ÀÀÆ÷»º´æ£º
ExpiresActive On
ExpiresDefault “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType text/css “access plus 1 month”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
Èý¡¢µ÷½âApacheÐÔÄÜÉèÖÃ
ApacheµÄÐÔÄÜÉèÖöÔÍøÕ¾µÄÏìÓ¦ËÙÂÊÓÐ×ÅÖ÷ÒªµÄÓ°Ïì¡£ÔÚ¸¡Í¼Ãæ°åÖУ¬ÎÒÃÇ¿ÉÒÔÔÚ¡°Apache¡±Ñ¡ÏÏÂÕÒµ½¡°ÐÔÄÜÉèÖá±£¬È»ºó¶ÔÒÔÏÂÉèÖþÙÐе÷½â£º
1.ÐÞ¸ÄMaxClients²ÎÊý£ºÕâ¸ö²ÎÊýÖ¸¶¨Apache½¨ÉèµÄÀú³Ì£¨»òỊ̈߳©µÄ×î´óÊýÄ¿¡£Ò»Ñùƽ³£À´Ëµ£¬Õâ¸öÖµÓ¦¸ÃÉèÖÃΪЧÀÍÆ÷ÄÚ´æµÄ10% ~ 30%¡£ÀýÈ磬ÈôÊÇЧÀÍÆ÷ÄÚ´æΪ2G£¬ÄÇô×î´óÀú³ÌÊýÓ¦¸ÃÉèÖÃΪ200 ~ 300¡£
2.¿ªÆôKeepAlive£ºKeepAliveÊÇÒ»¸öHTTPÐÒéÖеĻúÖÆ£¬ËüÔÊÐíÔÚͳһ¸öÅþÁ¬ÉϾÙÐжà¸öÇëÇóºÍÏìÓ¦¡£ÔÚApacheЧÀÍÆ÷ÖпªÆôKeepAlive¿ÉÒÔïÔÌÿ¸öÇëÇóµÄ¸ºÔØ£¬Ìá¸ßÍøÕ¾µÄÏìÓ¦ËÙÂÊ¡£ÔÚ¸¡Í¼Ãæ°åÖУ¬Ö»ÐèÒªÔÚ¡°ÐÔÄÜÉèÖá±Ñ¡ÏÖй´Ñ¡¡°¿ªÆôKeepAlive¡±¡£
3.ÐÞ¸ÄTimeout²ÎÊý£ºÕâ¸ö²ÎÊýÖ¸¶¨Apache´¦Öóͷ£ÇëÇóµÄ×ʱ¼ä¡£ÈôÊÇÇëÇóÁè¼ÝÕâ¸öʱ¼ä£¬Ð§ÀÍÆ÷½«»á¹Ø±ÕÅþÁ¬¡£Õâ¸öÖµÓ¦¸Ãƾ֤ĿµÄÍøÕ¾µÄÏìӦʱ¼äÀ´ÉèÖã¬Í¨³£Ó¦¸ÃÔÚ5 ~ 15ÃëÖ®¼ä¡£
ËÄ¡¢Ê¹Óûº´æ²å¼þ
³ýÁËÔÚApacheЧÀÍÆ÷ÖоÙÐлº´æÉèÖÃÖ®Í⣬ÎÒÃÇ»¹¿ÉÒÔʹÓûº´æ²å¼þÀ´ÓÅ»¯ÍøÕ¾µÄÐÔÄÜ¡£ÀýÈ磬ʹÓÃWordPressÍøվʱ£¬¿ÉÒÔ×°ÖÃW3 Total Cache»òWP Super CacheµÈ»º´æ²å¼þÀ´Ìá¸ßÍøÕ¾»á¼ûËÙÂÊ¡£
Î塢ѹËõ¾²Ì¬Îļþ
ѹËõÍøÕ¾µÄ¾²Ì¬Îļþ£¨ÈçCSS¡¢JavaScript¡¢HTMLµÈ£©¿ÉÒÔÓÐÓõØïÔÌËüÃǵľÞϸ£¬´Ó¶øïÔ̼ÓÔØʱ¼ä¡£ÔÚ¸¡Í¼Ãæ°åÖУ¬ÎÒÃÇ¿ÉÒÔÔÚ¡°Apache¡±Ñ¡ÏÏÂÕÒµ½¡°¿ªÆôGzipѹËõ¡±Ñ¡Ïî²¢¹´Ñ¡Ëü£¬´Ó¶ø¿ªÆôGzipѹËõ¹¦Ð§¡£
×ܽá
ApacheЧÀÍÆ÷µÄÐÔÄÜÓÅ»¯¹ØÓÚÌá¸ßÍøÕ¾µÄÏìÓ¦ËÙÂʺÍÓû§ÌåÑéºÜÊÇÖ÷Òª¡£Í¨¹ý¸¡Í¼Ãæ°å£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØ¾ÙÐлù´¡ÉèÖᢿªÆô»º´æ¡¢µ÷½âÐÔÄÜÉèÖá¢Ê¹Óûº´æ²å¼þÒÔ¼°Ñ¹Ëõ¾²Ì¬ÎļþµÈ²Ù×÷£¬´Ó¶øÓÐÓõØÌá¸ßÍøÕ¾µÄÐÔÄÜ¡£
ÒÔÉϾÍÊÇÔõÑùͨ¹ý¸¡Í¼Ãæ°å¾ÙÐÐApacheЧÀÍÆ÷µÄÐÔÄÜÓÅ»¯µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡