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Æô¶¯ÆðÀ´£¬È
Ïà¹ØÎĵµ£º
Àý×Ó. return() º¯ÊýµÄÓ÷¨
<?php
function square ($num)
{
return $num * $num;
}
echo square (4); // outputs '16'.
?>
º¯Êý²»ÄÜ·µ»Ø¶à¸öÖµ£¬µ«ÎªÁË»ñµÃ¼òµ¥µÄ½á¹û£¬¿ÉÒÔ·µ»ØÒ»¸öÁÐ±í¡£
Àý×Ó. ·µ»ØÒ»¸öÊý×éÒԵõ½¶à¸ö·µ»ØÖµ
<?php
function small_numbe ......
·½·¨Ò»£º
<?php
function extend_1($file_name)
{
$retval="";
$pt=strrpos($file_name, ".");
if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
return ($retval);
}
?>
·½·¨¶þ£º
function extend_2($file_name)
{
$extend = pathinfo($file_name);
$extend = strto ......
ת×Ô:http://www.w3school.com.cn/php/func_string_substr.asp
PHP substr() º¯Êý
PHP String º¯Êý
¶¨ÒåºÍÓ÷¨
substr() º¯Êý·µ»Ø×Ö·û´®µÄÒ»²¿·Ö¡£
Óï·¨
substr(string,start,length)
²ÎÊýÃèÊö
string
±ØÐè¡£¹æ¶¨Òª·µ»ØÆäÖÐÒ»²¿·ÖµÄ×Ö·û´®¡£
start
±ØÐè¡£¹æ¶¨ÔÚ×Ö·û´®µÄºÎ´¦¿ªÊ¼¡£
ÕýÊý - ÔÚ×Ö·û´®µÄÖ¸¶¨Î»Öÿª ......
ÔÎĵØÖ·£º http://blog.csdn.net/lmss82/archive/2010/05/10/5574772.aspx
ÕâÊÇÒ»¸öÍêÕû¿ÉÓõĴúÂ룬²¿·Ö´úÂëÀ´×ÔÓÚÍøÂç¡£
PHP:
5.26
JS»·¾³£º
jquery.js,jquery_form.js
ʹÓò½Ö裺
¿ªÆôAPC.
ÏÂÔØphp_apc.dll£¬ÐÞ¸Äphp.iniÎļþÔö¼ÓÒÔÏÂÄÚÈÝ£º
extension=php_apc.dll
apc.rfc1867 = On
´úÂ룺
<?php
//< ......
MySQL showµÄÓ÷¨
a. show tables»òshow tables from database_name; // ÏÔʾµ±Ç°Êý¾Ý¿âÖÐËùÓбíµÄÃû³Æ
b. show databases; // ÏÔʾmysqlÖÐËùÓÐÊý¾Ý¿âµÄÃû³Æ
c. show columns from table_name from database_name; »òshow columns from database_name.table_name; ......