Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Nginx+PHP+MySQLË«»ú»¥±¸¡¢È«×Ô¶¯Çл»·½°¸

ÔÚÉú²úÓ¦ÓÃÖУ¬Ä³Ì¨“Nginx+PHP+MySQL”½Ó¿ÚÊý¾Ý·þÎñÆ÷£¬°çÑݵĽÇÉ«Ê®·ÖÖØÒª£¬Èç¹û·þÎñÆ÷Ó²¼þ»òNginx¡¢MySQL·¢Éú¹ÊÕÏ£¬¶ø ¶Ìʱ¼äÄÚÎÞ·¨»Ö¸´£¬ºó¹û½«·Ç³£ÑÏÖØ¡£ÎªÁ˱ÜÃâµ¥µã¹ÊÕÏ£¬ÎÒÉè¼ÆÁË´ËÌ×·½°¸£¬±àдÁËfailover.sh½Å±¾£¬ÊµÏÖÁËË«»ú»¥±¸¡¢È«×Ô¶¯Çл»£¬¹ÊÕÏתÒÆʱ¼ä Ö»Ð輸ʮÃë¡£
Ò»¡¢Ë«»ú»¥±¸¡¢È«×Ô¶¯Çл»·½°¸£º
1¡¢ÍØÆËͼ£º
2¡¢½âÊÍ£º
(1)¡¢¼ÙÉèÍâÍøÓòÃûblog.s135.com½âÎöµ½ÍâÍøÐéÄâIP 72.249.146.214ÉÏ£¬ÄÚÍøhostsÉèÖÃdb10¶ÔÓ¦ÄÚÍøÐéÄâIP 192.168.146.214
(2)¡¢Ä¬ÈÏÇé¿öÏ£¬ÓÉÖ÷»ú°ó¶¨ÄÚ¡¢ÍâÍøÐéÄâIP£¬±¸»ú×÷Ϊ±¸·Ý£¬µ±Ö÷»úµÄMySQL¡¢Nginx»ò·þÎñÆ÷³öÏÖ¹ÊÕÏÎÞ·¨·ÃÎÊʱ£¬±¸»ú»á×Ô¶¯½Ó¹ÜÄÚ¡¢ÍâÍø ÐéÄâIP¡£Á½Ì¨·þÎñÆ÷¶¼Æô¶¯¸ºÔð¼à¿Ø¡¢×Ô¶¯Çл»ÐéÄâIPµÄÊØ»¤½ø³Ì/usr/bin/nohup /bin/sh /usr/local/webserver/failover/failover.sh 2>&1 > /dev/null &
(3)¡¢Ö÷»úºÍ±¸»úÉϵÄMySQL·þÎñÆ÷»¥ÎªÖ÷´Ó£¬»¥Ïàͬ²½¡£ÔÚÖ÷»ú´¦Óڻ״̬£¨¼´ÓÉÖ÷»ú°ó¶¨ÐéÄâIP£©Ê±£¬¶ÁдÖ÷»úµÄ MySQL£¬Ð´µ½Ö÷»úµÄÊý¾Ý»áͬ²½µ½±¸»ú£»ÔÚ±¸»ú´¦Óڻ״̬ʱ£¬¶Áд±¸»úµÄMySQL£¬Ð´µ½±¸»úµÄÊý¾Ý»áͬ²½µ½Ö÷»ú£¨Èç¹ûÖ÷»úÉϵÄMySQLËÀµôÔÝʱÎÞ ·¨Í¬²½£¬Ö÷»úÉϵÄMySQL»Ö¸´ºó£¬Êý¾Ý»á×Ô¶¯´Ó±¸»úÉÏͬ²½¹ýÀ´£¬·´Ö®ÒàÈ»£©¡£
(4)¡¢Ö÷»ú´¦Óڻ״̬ʱ£¬Ã¿20Ãë»á°Ñ /data0/htdocs/£¨ÍøÒ³¡¢³ÌÐò¡¢Í¼Æ¬´æ·ÅĿ¼£©¡¢/usr/local/webserver/php/etc/£¨php.iniµÈÅäÖÃÎļþÄ¿ ¼£©¡¢/usr/local/webserver/nginx/conf/£¨NginxÅäÖÃÎļþĿ¼£©Èý¸öĿ¼ÏµÄÎļþͨ¹ýrsyncÍÆË͵½±¸»ú·þÎñÆ÷ÉÏ µÄ¶ÔӦĿ¼£¨ÔöÁ¿ÍÆËÍ£¬Á½Ì¨·þÎñÆ÷ÉÏÒ»ÑùµÄÎļþ²»»áÖظ´ÍÆËÍ£©£¬·´Ö®Èç¹û±¸»ú´¦Óڻ״̬ʱ£¬Ã¿20Ãë»á³¢ÊÔ°ÑÎļþÍÆË͵½Ö÷»ú¡£rsyncµÄÅäÖÃÎļþ¼ûÁ½ ̨·þÎñÆ÷µÄ/etc/rsyncd.conf£¬rsyncÊØ»¤½ø³ÌµÄÆô¶¯ÃüÁîΪrsync –daemon
3¡¢×Ô¶¯Çл»Á÷³Ì
(1)¡¢Ö÷»úĬÈÏ°ó¶¨ÄÚ¡¢ÍâÍøÐéÄâIP£¬µ±Ö÷»úµÄMySQL¡¢NginxÎÞ·¨·ÃÎÊ»ò·þÎñÆ÷å´»ú£¬Ö÷»úÉϵÄfailover.shÊØ»¤½ø³Ì»á×Ô¶¯Õª³ý×Ô¼º °ó¶¨µÄÄÚ¡¢ÍâÍøÐéÄâIP£¨Èç¹ûÖ÷»úÉϵÄfailover.shËÀµô£¬ÎÞ·¨Õª³ý×Ô¼º°ó¶¨µÄÐéÄâIPҲû¹Øϵ£©£¬±¸»úÉϵÄfailover.shÊØ»¤½ø³Ì»á×Ô ¶¯½Ó¹Ü±¸»úÔ­À´°ó¶¨µÄÄÚ¡¢ÍâÍøÐéÄâIP£¬²¢·¢ËÍARPing°ü¸øÄÚ¡¢ÍâÍøÍø¹Ø¸üÐÂMAC£¬Ç¿Ðнӹܡ£
(2)¡¢±¸»ú°ó¶¨ÐéÄâIPºó£¬»á·¢ËÍARPing°ü¸øÄÚ¡¢ÍâÍøÍø¹Ø£¬Í¨ÖªÍø¹Ø¸üÐÂÐéÄâIPµÄMACµØַΪ±¸»úµÄMACµØÖ·£¬´Ó¶ø±£Ö¤ÁËÇл»ºóÄܹ»Í¨¹ýÐéÄâIP¼°Ê±·ÃÎʵ½±¸»ú¡£
(3)¡¢Èç¹ûÖ÷»úµÄMySQL¡¢NginxÆô¶¯ÆðÀ´£¬È


Ïà¹ØÎĵµ£º

PHPÖÐsession_registerº¯ÊýÏê½â


Óï·¨: boolean session_register(string name);
×¢²áеıäÁ¿¡£
·µ»ØÖµ: ²¼¶ûÖµ
º¯ÊýÖÖÀà: ×ÊÁÏ´¦Àí
ÄÚÈÝ˵Ã÷
±¾º¯ÊýÔÚÈ«Óò±äÁ¿ÖÐÔö¼ÓÒ»¸ö±äÁ¿µ½Ä¿Ç°µÄ Session Ö®ÖС£²ÎÊý name ¼´ÎªÓû¼ÓÈëµÄ±äÁ¿Ãû¡£³É¹¦Ôò·µ»Ø true Öµ¡£
¼ÙÈçÔÚÍ·Îļþ£¬¿ªÆôsession,¼´Ê¹ÓÃsession_start()º¯ÊýºóÃæ¼ÓÉÏsession_register(string na ......

PHP ·µ»ØÖµ

Àý×Ó. return() º¯ÊýµÄÓ÷¨
<?php
function square ($num)
{
    return $num * $num;
}
echo square (4);   // outputs '16'.
?>
º¯Êý²»ÄÜ·µ»Ø¶à¸öÖµ£¬µ«ÎªÁË»ñµÃ¼òµ¥µÄ½á¹û£¬¿ÉÒÔ·µ»ØÒ»¸öÁÐ±í¡£
Àý×Ó. ·µ»ØÒ»¸öÊý×éÒԵõ½¶à¸ö·µ»ØÖµ
<?php
function small_numbe ......

ÓÃPHPʵÏÖ¼òµ¥µÄ·´Ïò×î´óÆ¥ÅäÖÐÎÄ·Ö´Ê£¨´úÂ룩

ÀàÎļþwordsplit.class.php£º
<?php
/********************************************************************
* DirCMSÖÐÎÄ·Ö´ÊÀà beta 1.0
* ---------------------------
* begin : 2010-5-11 beta 1.0
* update : 2 ......

PHP·â×°ÀàЧÂʲâÊÔ

½ñÌì¸ÕѧÍêmysqli£¬È¥ÎÒµÄIDCÔËÓªÉÌÄÇ¿´ÁËһϣ¬·¢ÏÖËûÃǵÄÐéÄâÖ÷»ú¾ÓÈ»²»Ö§³Ö£¬ÎÒÓÖÈ¥ÆäËû¼¸¼Ò¿´ÁË¿´£¬ÓеÄÖ§³ÖÓеIJ»Ö§³Ö¡£
ÎÒ¾ÍÏë×Ô¼ºÐ´¸öÀ࣬ÈÃËûÈ¥Åжϣ¬ÄÜÓÃmysqli¾ÍÓÃmysqli£¬·ñÔò¾ÍÓÃԭʼµÄmysqlº¯Êý¡£²»¹ýÎÊÌâÂíÉϾÍÀ´ÁË£¬×Ô¼ºÐ´Àà»á²»»áµ¼ÖÂÖ´ÐÐЧÂʱäµÍÁËÄØ£¿ÓÚÊÇÎҾͽøÐÐÁËÈçϲâÊÔ¡£
ÕâÊÇÓÃÀ´¼ÆʱµÄÀࣺ
/* ......

Ò»¸öPHPÈÕÀú³ÌÐò

//calendar.php
<?¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
/*******************************¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡*¡¡ ÓÃÀ´ÅжÏÊÇ·ñÈòÄêµÄº¯Êý¡¡¡¡*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡*¡¡ ¿ÉÒÔ¸ù¾Ý¸ü¸´ÔÓµÄËã·¨¸Ä½ø¡¡*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ