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ÀàLibchart£¬ÕâÊǸöÍâ¹úÈË£¨·ÇÖйú¹ú¼®µÄµØÇòÈË£¬±»³ÆΪÍâ¹úÈË£¡£©Ð´µÄÃâ·ÑÀ࣡ʹÓÃÆðÀ´·Ç
³£¼òµ¥¡£¿´³öÀ´ÁË°É£¬ÎÒÃÇÊÇÒªÓÃÒ»¸öÍâ¹úÈËдµÄPHP´´½¨Öù״ͼ£¬±ý״ͼ£¬ºÍÏßÐÔͼµÄÀ࣬À´¹¤×÷µÄ¡£Èç¹ûÄãҪѧϰÕâ¸öÀàµÄд·¨£¬ÄãÒ²¿ÉÒÔ°ÑÕâ¸öÀàÏÂÔØÏÂÀ´¿´¿´Íâ¹úÈ˵Ä˼·£¡
ÎÒÃÇ¿ªÊ¼°É ......
[root@BIND9-master /usr/local/bin]# php --ini
Configuration File (php.ini) Path: /usr/local/etc
Loaded Configuration File: /usr/local/Zend/etc/php.ini
Scan for additional .ini files in: /usr/local/etc/php
Additional .ini files parsed: &n ......
ip_contrl.php:
<?php
//include('header.php');
$ipaddr = $_POST['ipaddr'];
$netmask = $_POST['netmask'];
$gateway = $_POST['gateway'];
$mac = $_POST['mac'];
$dns1 = $_POST['dns1'];
$dns2 = $_POST['dns2'];
//echo "ipaddr=$ipaddr;netm ......
ÎÒÓõÄÊÇmysql5.0£¬
ÎÒ³ÌÐòÖÐÓõ½ÁËÒ»¾äsqlÊÇ
SQL code
select count(DISTINCT id) from Policyinfo p where p.filename not in
(select p2.filename from Policyreadinfo p2 where p2.reader='test')
µ«ÊÇÿ´ÎÔÚ³ÌÐòÖÐÿ´ÎÖ´ÐÐÕâ¾äsqlʱÍøÒ³¾ÍÌØÂý£¬Òª10¶àÃ룬¶øÕâ2¸ö±íµÄ¼Ç¼ÐÐÊýÒ²¾Í1000¶à¶øÒÑ£¬ÎÒ°ÑÕâ¾äsqlµ¥¶ÀÄ ......