PHPÆóÒµ¼¶Ó¦ÓÃÖ®³£¼û»º´æ¼¼Êõƪ
Æձ黺´æ¼¼Êõ
Êý¾Ý»º´æ£ºÕâÀïËù˵µÄÊý¾Ý»º´æÊÇÖ¸Êý¾Ý¿â²éѯ»º´æ£¬Ã¿´Î·ÃÎÊÒ³ÃæµÄʱºò,¶¼»áÏȼì²âÏàÓ¦µÄ»º´æÊý¾ÝÊÇ·ñ´æÔÚ£¬Èç¹û²»´æÔÚ£¬¾ÍÁ¬½ÓÊý¾Ý¿â£¬µÃµ½Êý¾Ý£¬ ²¢°Ñ²éѯ½á¹ûÐòÁл¯ºó±£´æµ½ÎļþÖУ¬ÒÔºóͬÑùµÄ²éѯ½á¹û¾ÍÖ±½Ó´Ó»º´æ±í»òÎļþÖлñµÃ¡£
ÓõÄ×î¹ãµÄÀý×Ó¿´DiscuzµÄËÑË÷¹¦ÄÜ£¬°Ñ½á¹ûID»º´æµ½Ò»¸ö±íÖУ¬Ï´ÎËÑË÷Ïàͬ¹Ø¼ü×ÖʱÏÈËÑË÷»º´æ±í¡£
¾Ù¸ö³£Óõķ½·¨£¬¶à±í¹ØÁªµÄʱºò£¬°Ñ¸½±íÖеÄÄÚÈÝÉú³ÉÊý×é±£´æµ½Ö÷±íµÄÒ»¸ö×Ö¶ÎÖУ¬ÐèÒªµÄʱºòÊý×é·Ö½âһϣ¬ÕâÑùµÄºÃ´¦ÊÇÖ»¶ÁÒ»¸ö±í£¬»µ´¦¾ÍÊÇÁ½¸ö Êý¾Ýͬ²½»á¶à²»ÉÙ²½Ö裬Êý¾Ý¿âÓÀÔ¶ÊÇÆ¿¾±£¬ÓÃÓ²ÅÌ»»Ëٶȣ¬ÊÇÕâ¸öµÄ¹Ø¼üµã¡£
Ò³Ã滺´æ£º
ÿ´Î·ÃÎÊÒ³ÃæµÄʱºò£¬¶¼»áÏȼì²âÏàÓ¦µÄ»º´æÒ³ÃæÎļþÊÇ·ñ´æÔÚ£¬Èç¹û²»´æÔÚ£¬¾ÍÁ¬½ÓÊý¾Ý¿â£¬µÃµ½Êý¾Ý£¬ÏÔʾҳÃ沢ͬʱÉú³É»º´æÒ³ÃæÎļþ£¬ÕâÑùÏ´ηÃÎÊ µÄʱºòÒ³ÃæÎļþ¾Í·¢»Ó×÷ÓÃÁË¡£(Ä£°åÒýÇæºÍÍøÉϳ£¼ûµÄһЩ»º´æÀàͨ³£Óд˹¦ÄÜ)
ʱ¼ä´¥·¢»º´æ£º
¼ì²éÎļþÊÇ·ñ´æÔÚ²¢ÇÒʱ¼ä´ÁСÓÚÉèÖõĹýÆÚʱ¼ä,Èç¹ûÎļþÐ޸ĵÄʱ¼ä´Á±Èµ±Ç°Ê±¼ä´Á¼õÈ¥¹ýÆÚʱ¼ä´Á´ó£¬ÄÇô¾ÍÓûº´æ£¬·ñÔò¸üлº´æ¡£
ÄÚÈÝ´¥·¢»º´æ£º
µ±²åÈëÊý¾Ý»ò¸üÐÂÊý¾Ýʱ£¬Ç¿ÖƸüлº´æ¡£
¾²Ì¬»º´æ£º
ÕâÀïËù˵µÄ¾²Ì¬»º´æÊÇÖ¸¾²Ì¬»¯£¬Ö±½ÓÉú³ÉHTML»òxmlµÈÎı¾Îļþ£¬ÓиüеÄʱºòÖØÉú³ÉÒ»´Î£¬ÊʺÏÓÚ²»Ì«±ä»¯µÄÒ³Ã棬Õâ¾Í²»ËµÁË¡£
ÒÔÉÏÄÚÈÝÊÇ´úÂ뼶µÄ½â¾ö·½°¸£¬ÎÒÖ±½ÓCP±ðµÄ¿ò¼Ü£¬Ò²ÀÁµÃ¸Ä£¬ÄÚÈݶ¼²î²»¶à£¬ºÜÈÝÒ×¾Í×öµ½£¬¶øÇһἸÖÖ·½Ê½Ò»ÆðÓ㬵«ÏÂÃæµÄÄÚÈÝÊÇ·þÎñÆ÷¶ËµÄ»º´æ·½ °¸£¬·Ç´úÂ뼶µÄ£¬ÒªÓж෽µÄºÏ×÷²ÅÄÜ×öµ½
Äڴ滺´æ:
MemcachedÊǸßÐÔÄܵģ¬·Ö²¼Ê½µÄÄÚ´æ¶ÔÏ󻺴æϵͳ£¬ÓÃÓÚÔÚ¶¯Ì¬Ó¦ÓÃÖмõÉÙÊý¾Ý¿â¸ºÔØ£¬ÌáÉý·ÃÎÊËٶȡ£
ÕâÀï˵ÏÂMemcachedµÄÀý×Ó£º
$memcache = new Memcache; $memcache->connect(¡®localhost¡¯, 11211) or die (¡°Could not connect¡±); $version = $memcache->getVersion(); echo ¡°Server¡¯s version: ¡°.$version.¡±\n¡±; $tmp_object = new stdClass; $tmp_object->str_attr = ¡®test¡¯; $tmp_object->int_attr = 123; $memcache->set(¡®key¡¯, $tmp_object, false, 10) or die (¡°Failed to save data at the server¡±); echo ¡°Store data in the cache (data will expire in 10 seconds)\n¡±; $get_result = $memcache->get(¡®key¡¯); echo ¡°Data from the cache:\n¡±; var_dump($get_result);¶Á¿âµÄÀý×Ó£º
$sql = ¡®SELECT * FROM users¡¯; $key = md5($sql); //memcached ¶ÔÏó±êʶ·û if ( !($datas = $mc->get($key)) ) { // ÔÚ memcached ÖÐδ»ñÈ¡µ½»º´æÊý¾Ý£¬ÔòʹÓÃÊý¾Ý¿â²éѯ»ñÈ¡¼Ç¼¼¯¡£ echo ¡°n¡±.str_pad(¡®Read datas from MySQL.¡¯, 60, ¡®_¡¯).¡±n¡±; $conn = mysql_connect(¡®localhost¡¯, ¡®test¡¯, ¡®test¡¯); mysql_select_db(¡®test¡¯); $result = mysql_query($sql); while ($row = mysql_fetch_object($result)) $datas[] = $row; // ½«Êý¾Ý¿âÖлñÈ¡µ½µÄ½á¹û¼¯Êý¾Ý±£´æµ½ memcached ÖУ¬ÒÔ¹©Ï´ηÃÎÊʱʹÓᣠ$mc->add($key, $datas); } else { echo ¡°n¡±.str_pad(¡®Read datas from memcached.¡¯, 60, ¡®_¡¯).¡±n¡±; } var_dump($datas);
phpµÄ»º³åÆ÷£º
ÓÐeaccelerator£¬ apc£¬ phpa£¬xcache£¬Õâ¸öÕâ¸ö¾Í²»ËµÁË°É£¬ËÑË÷Ò»¶ÑÒ»¶ÑµÄ£¬×Ô¼º¿´À²£¬ÖªµÀÓÐÕâÍæÒâ¾ÍOK
MYSQL»º´æ£º
ÕâÒ²Ëã·Ç´úÂ뼶µÄ£¬¾µäµÄÊý¾Ý¿â¾ÍÊÇÓõÄÕâÖÖ·½Ê½£¬¿´ÏÂÃæµÄÔËÐÐʱ¼ä£¬0.09xxxÖ®ÀàµÄ
ÎÒÌù¶Î¸ù¾ÝÀ¶É«ÄǼһïÐ޸ĺ󲿷Ömy.ini °É£¬2GµÄMYISAM±í¿ÉÒÔÔÚ0.05S×óÓÒ£¬¾Ý˵ËûÇ°ºó¸ÄÁËÓпìÒ»Äê
[client] ¡¡ default-character-set=gbk default-storage-engine=MYISAM max_connections=600 max_connect_errors=500 back_log=200 interactive_timeout=7200 query_cache_size=64M ¡¡ table_cache=512 ¡¡ myisam_max_sort_file_size=100G myisam_max_extra_sort_file_size=100G myisam_sort_buffer_size=128M key_buffer_size=1024M read_buffer_size=512M ¡¡ thread_concurrency=8»ùÓÚ·´Ïò´úÀíµÄWeb»º´æ:
ÈçNginx£¬SQUID£¬mod_PRoxy(apache2ÒÔÉÏÓÖ·ÖΪmod_proxyºÍmod_cache)
NGINXµÄÀý×Ó
<nginx.conf>
#user nobody; worker_processes 4; error_log logs/error.log crit; pid logs/nginx.pid; worker_rlimit_nofile 10240; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; tcp_nodelay on; # server pool upstream bspfrontsvr { server 10.10.10.224:80 weight=1; server 10.10.10.221:80 weight=1; } upstream bspimgsvr { server 10.10.10.201:80 weight=1; } upstream bspstylesvr { server 10.10.10.202:80 weight=1; } upstream bsphelpsvr { server 10.10.10.204:80 weight=1; } upstream bspwsisvr { server 10.10.10.203:80 weight=1; } upstream bspadminsvr { server 10.10.10.222:80 weight=1; } upstream bspbuyersvr { server 10.10.10.223:80 weight=1; } upstream bspsellersvr { server 10.10.10.225:80 weight=1; } upstream bsploginsvr { server 10.10.10.220:443 weight=1; } upstream bspregistersvr { server 10.10.10.220:80 weight=1; } log_format test_com ¡®$remote_addr ¨C $remote_user [$time_local] ¡°$request¡± ¡® ¡®$status $body_bytes_sent ¡°$http_referer¡± ¡°$http_user_agent¡± ¡®; #¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C #img.test.com server { listen 10.10.10.230:80; server_name img.test.com; location / { proxy_pass http://bspimgsvr; include proxy_setting.conf; } access_log logs/img.log test_com; } #style.test.com server { listen 10.10.10.230:80; server_name style.test.com; location / { proxy_pass http://bspstylesvr; include proxy_setting.conf; } access_log logs/style.log test_com; } #help.test.com server { listen 10.10.10.230:80; server_name help.test.com; location / { proxy_pass http://bsphelpsvr; include proxy_setting.conf; } access_log logs/help.log test_com; } #admin.test.com server { listen 10.10.10.230:80; server_name admin.test.com; location / { proxy_pass http://bspadminsvr; include proxy_setting.conf; } access_log logs/admin.log test_com; } #buyer.test.com server { listen 10.10.10.230:80; server_name buyer.test.com; location / { proxy_pass http://bspbuyersvr; include proxy_setting.conf; } access_log logs/buyer.log test_com; } #seller.test.com server { listen 10.10.10.230:80; server_name seller.test.com; location / { proxy_pass http://bspsellersvr; include proxy_setting.conf; } access_log logs/seller.log test_com; } #wsi.test.com server { listen 10.10.10.230:80; server_name wsi.test.com; location / { proxy_pass http://bspwsisvr; include proxy_setting.conf; } access_log logs/wsi.log test_com; } #www.test.com server { listen 10.10.10.230:80; server_name www.test.com *.test.com; location ~ ^/NginxStatus/ { stub_status on; access_log off; } location / { proxy_pass http://bspfrontsvr; include proxy_setting.conf; } access_log logs/www.log test_com; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } #login.test.com server { listen 10.10.10.230:443; server_name login.test.com; ssl on; ssl_certificate cert.pem; ssl_certificate_key cert.key; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; ssl_prefer_server_ciphers on; location / { proxy_pass https://bsploginsvr; include proxy_setting.conf; } access_log logs/login.log test_com; } #login.test.com for register server { listen 10.10.10.230:80; server_name login.test.com; location / { proxy_pass http://bspregistersvr; include proxy_setting.conf; } access_log logs/register.log test_com; } } <conf/proxy_setting.conf> 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; mod_proxyµÄÀý×Ó£º <VirtualHost *> ServerName www.zxsv.com ServerAdmin admin@zxsv.com # reverse proxy setting ProxyPass / http://www.zxsv.com:8080/ ProxyPassReverse / http://www.zxsv.com:8080/ # cache dir root CacheRoot ¡°/var/www/proxy¡± # max cache storage CacheSize 50000000 # hour: every 4 hour CacheGcInterval 4 # max page expire time: hour CacheMaxExpire 240 # Expire time = (now ¨C last_modified) * CacheLastModifiedFactor CacheLastModifiedFactor 0.1 # defalt expire tag: hour CacheDefaultExpire 1 # force complete after precent of content retrived: 60-90% CacheForceCompletion 80 CustomLog /usr/local/apache/logs/dev_access_log combined </VirtualHost>¶øSQUIDµÄÀý×ÓÎҾͲ»ËµÃ÷ÁË£¬Õâ·½ÃæÍøÉÏÓÐдµÄÌ«¶à£¬´ó¼Ò×Ô¼ºËÑË÷Ò»ÏÂ
DNSÂÖѯ£º
BINDÊÇÒ»¿î¿ª·ÅÔ´ÂëµÄDNS·þÎñÆ÷Èí¼þ£¬Õâ¸öҪ˵ÆðÀ´¾Í´óÁË£¬×Ô¼ºËÑË÷È¥£¬´ó¼ÒÖªµÀÓÐÕâ¸ö¶«Î÷¾ÍÐÐÁË¡£
ÎÒÖªµÀµÄÓÐchinacache µÈ´óÕ¾¾ÍÊÇÕâÑù×öµÄ£¬Ëµ¼òµ¥µã¾ÍÊǶà·þÎñÆ÷À²£¬°Ñͬһ¸öÒ³Ãæ»òÎļþ»º´æµ½²»Í¬µÄ·þÎñÆ÷ÉÏ£¬°´Äϱ±×Ô¶¯½âÎöµ½Ïà¹ØµÄ·þÎñÆ÷ÖС£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- 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ÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ