×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõôʹÓÃThinkPHP¾ÙÐÐÂþÑÜʽ°²ÅÅ

Ò»¡¢¸ºÔØƽºâ

ÔÚ¾ÙÐÐÂþÑÜʽ°²ÅŵÄʱ¼ä £¬¸ºÔØƽºâÊDZز»¿ÉÉÙµÄÒ»²¿·Ö £¬Ëü¿ÉÒÔͨ¹ý½«ÇëÇó·ÖÅɵ½¶à¸öЧÀÍÆ÷ÉÏÀ´Æ½ºâЧÀÍÆ÷µÄ¸ºÔØ ¡£Õë¶ÔÕâÒ»ÎÊÌâ £¬ÎÒÃÇ¿ÉÒÔʹÓà Nginx À´¾ÙÐÐʵÏÖ ¡£

NginxÊÇÒ»¿î¸ßЧµÄWebЧÀÍÆ÷ £¬²»µ«¿É×÷Ϊ¸ºÔØƽºâÆ÷ £¬»¹¿É³äµ±¾²Ì¬×ÊԴЧÀÍÆ÷ ¡£½öÐèÔÚ Nginx ÉϾÙÐÐÉèÖà £¬±ã¿ÉʵÏÖʹÓà Nginx ¾ÙÐиºÔØƽºâ ¡£

ÒÔÏÂÊÇÒ»¸ö½ÏΪ¼òÆ Nginx ÉèÖÃʾÀý£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

upstream backend {
    server backend1;
    server backend2;
    server backend3;
}

server {
    listen 80;
    
    location / {
        proxy_pass http://backend;
    }
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇʹÓà upstream Ö¸Áî½ç˵ÁËÒ»¸öºó¶ËЧÀÍÆ÷µÄÁбí £¬È»ºó½«Õâ¸öÁбíת´ï¸ø proxy_pass Ö¸Áî ¡£ÕâÑù £¬µ±ÎÒÃǵÄÇëÇóµÖ´ï Nginx ºó £¬Nginx »á×Ô¶¯½«ÇëÇóת·¢µ½ºó¶ËЧÀÍÆ÷ÉÏ ¡£

¶þ¡¢Session ¹²Ïí

ÔÚÂþÑÜʽ°²ÅÅÖÐ £¬ÎÒÃǾ­³£ÐèÒªÔÚ¶à¸öЧÀÍÆ÷Ö®¼ä¹²ÏíÊý¾Ý £¬ÀýÈç Session Êý¾Ý ¡£ÈôÊÇÎÒÃÇ´¿´âµØ½« Session Êý¾Ý´æ·ÅÔÚij¸öЧÀÍÆ÷µÄÄÚ´æÖÐ £¬ÄÇôÆäËûЧÀÍÆ÷½«ÎÞ·¨»á¼ûÕâ¸ö Session Êý¾Ý ¡£

Òª½â¾öÕâ¸öÎÊÌâ £¬ÎÒÃÇ¿ÉÒÔ½ÓÄÉÄڴ滺´æЧÀÍ £¬ÀýÈç Redis »ò Memcached À´ÊµÏÖ ¡£Í¨¹ýÕâЩЧÀÍ £¬¿ÉÒÔʵÏÖÊý¾ÝÔÚ¶ą̀ЧÀÍÆ÷Ö®¼äµÄ¹²Ïí £¬½«Æä´æ·ÅÔÚÂþÑÜʽÄڴ滺´æÖÐ ¡£

ÔÚ ThinkPHP ÖÐ £¬ÎÒÃÇ¿ÉÒÔ½èÖú think\cache\driver\Redis »ò think\cache\driver\Memcached Àà¾ÙÐлº´æ²Ù×÷ ¡£ÒÔÏÂÊÇÒ»¸öʹÓà Redis ¾ÙÐлº´æµÄÀý×Ó£º

$redis = new \think\cache\driver\Redis();

$redis->set('key', 'value');

$value = $redis->get('key');

µÇ¼ºó¸´ÖÆ

Èý¡¢Îļþ¹²Ïí

ÓÐЩӦÓÃÐèÒª¹²Ïí¶àÖÖÎļþ £¬ÀýÈç´úÂ롢ͼƬ¡¢Îı¾µÈµÈ £¬³ýÁË Session Êý¾Ý ¡£ÎªÁËʵÏÖÎļþ¹²Ïí £¬ÎÒÃÇ¿ÉÒÔʹÓÃÂþÑÜʽÎļþϵͳÀ´¾ÙÐд洢 ¡£

ÂþÑÜʽÎļþϵͳ¿ÉÒÔ½«ÎļþÊèÉ¢ÔÚ¶ą̀ЧÀÍÆ÷ÉϾÙÐд洢 £¬ÕâÑùÏà±È¹Å°åµÄµ¥»ú´æ´¢ £¬ÂþÑÜʽ´æ´¢Ô½·¢Çå¾²¿É¿¿ ¡£ÔÚ ThinkPHP ÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓà think\filesystem\driver\Qiniu À´²Ù×÷ÆßÅ£Ôƹ¤¾ß´æ´¢ £¬ÊµÏÖÎļþµÄÂþÑÜʽ´æ´¢ ¡£

ÒÔÏÂÊÇÒ»¸öʹÓÃÆßÅ£Ôƹ¤¾ß´æ´¢¾ÙÐÐÎļþ´æ´¢µÄÀý×Ó£º

$config = [
    'accessKey' => 'your access key',
    'secretKey' => 'your secret key',
    'bucket' => 'your bucket name',
];

$filesystem = \think\filesystem\Driver::Qiniu($config);

// ÉÏ´«Îļþ
$filesystem->write('test.txt', 'hello, world!');

// ÏÂÔØÎļþ
$content = $filesystem->read('test.txt');

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇÔõôʹÓÃThinkPHP¾ÙÐÐÂþÑÜʽ°²ÅŵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ