ãã®ããã°ã CentOS + apache + mod_php + MySQL ãã GAE/php ã«ç§»è¡ãã話2016-08-01
ããã®ã¨ããæ°é±éããã¦ããã®ããã°ãã²ãã¦ã¯ www.otchy.net å
¨ã¦ã CentOS + apache + php_mod + MySQL ã ã£ãç°å¢ãããGAE/php ã®ç°å¢ã¸ç§»è¡ããä½æ¥ããã¦ãã¦ãããããä¸éãå®äºããã®ã§ãã©ããã£ãä½æ¥ãè¡ã£ãã®ããã¾ã¨ãã¦ãããã¨æãã¾ãã
ã§ããã以åããããã¨èª¿ã¹ãã¨ãããã¯ãå¶éãå¤ããã¼ãããããã°ãç«ã¡ä¸ãã¦ãå®å ¨ã« wordpress.com ã«ä¹ã£ããã®ã§ããã°ããªã楽ã§ã¯ãããã®ã®ãããã®ããã«ããã§ã«ã³ã³ãã³ãè³ç£ãæã£ã¦ããããå¤å°ã¯åã£ããã¨ãããããã¨æãã¨ãããªãé¢å (ãããã¯ä¸å¯è½) ã¨ããç¹ã§ãä»ã®é¸æè¢ãæ¢ãã¦ãã¾ããã
ãã®å¾ãæè¿ãã£ãããã¡ã³ã«ãªã£ã GAE 㧠WP ãåãã¨ç¥ãã¨ããã«ãªãããããªã£ãããã«ã¯ãã GAE/php 以å¤ã®é¸æè¢ã¯ããå¾ãªããã¨è¨ããã¨ã§ä»åã®ç§»è¡ä½æ¥ã«è¸ã¿åãã¾ããããã以éã§ã¯å®éã«ã©ã®ãããªä½æ¥ãè¡ã£ããé ã追ã£ã¦è§£èª¬ãã¦ãããã¨æãã¾ãã
å ã ã® WP èªä½ãè²ã ãªã·ã¼ã³ã§ãã®ã¾ã¾ãã¼ã«ã«ãµã¼ãã«ãã¡ã¤ã«ãæ¸ãè¾¼ãã§ä½¿ããã¨ããå¾åã«ããã®ã§ãããGAE ã®ã¦ã§ããµã¼ãã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯ãä¸åã®ãã¡ã¤ã«æ¸ãè¾¼ã¿ãç¦ãããã¦ãã¦ãããããã¼ã«ã«ãã¡ã¤ã«ã«ä¾åããæ©è½ã¯ããã®ã¾ã¾ã ã¨ãã¨ãã¨ãã¨ã©ã¼ã«ãªã£ã¦ä½¿ãã¾ããã
ã¾ããGAE ã§ã¯åºæ¬çã«ãã£ã¹ã¯ã¸ã®ã¢ã¯ã»ã¹ãé«ä¾¡ã§ããããã«è¨è¨ããã¦ãã¾ããéã« memcached ã¯æ¨æºã§ä½¿ããããã«ãªã£ã¦ãã¦ã¨ã¦ãå®ä¾¡ã«è¨å®ããã¦ããã®ã§ãå¯è½ã§ããã°ãã£ã¹ã¯ã¢ã¯ã»ã¹ããªãã¹ãé¿ããããã©ãã©ããã£ãã·ã¥ã¯æ´»ç¨ãã¦ããã¹ãã§ãã
ãããæ¢åã® WP ã§ã¯å¯¾å¿ãã¦ããªãé¨åããGAE ã®ããã¼ã«åããã¦æãåºãã¦ãããã®ããã® WP ãã©ã°ã¤ã³ã§ããã¨è¨ãã¾ãã
ãã¦ãã¾ãã¯ã¾ã£ãããªç°å¢ã§ WP ãåããã¦ã¿ã¦ãã¨ããããã¡ããã¨åä½ããã¨ããäºã確ããããã£ãã®ã§ãWordPressãGAEã§ç°¡åã«ä½¿ã10ã®ã¹ããã ã大ãã«åèã«ããã¦ããã ããã»ããã¢ãããã¦ã¿ã¾ãããè¨äºãå°ãå¤ããã®ãªã®ã§ãç»é¢ã®ã¹ã¯ãªã¼ã³ã·ã§ãããªã©ä»ã®ãã¼ã¸ã§ã³ã¨ã¯ç°ãªãé¨åãå¤ã ããã¾ããããããã¯åºæ¬çã«èªã¿æ¿ãã§åé¡ç¡ãé²ããã¨ãåºæ¥ã¾ããã
ä¸ç¹å¤§ããç°ãªã£ãã®ã¯ãCloud SQL ã¤ã³ã¹ã¿ã³ã¹ã«é¢ãã¦ã®é¨åã§ããç¾å¨ã¯ãCloud SQL 第2ä¸ä»£ã¨ããé«ããã©ã¼ãã³ã¹ã謳ã£ãæ°ãã¼ã¸ã§ã³ã®å©ç¨ãæ¨å¥¨ããã¦ãã¾ããããã¯ãã¼ã¿çã¨ããæ±ãã«ãªã£ã¦ãã¦ãç¾ç¶ã§ã¯ SLA ã®ä¿è¨¼ããªãã£ããããã¤ã³ãã¤ã³ã¿ã¤ã ãªã«ã㪠(ãµã¼ãã¯ã©ãã·ã¥ç´åã¾ã§æ»ãããªã«ããª) ãåºæ¥ãªãã£ããã¨ããä¸å©ãªç¹ãããã¾ããå人ããã°ã§æ°ã«ãããã®ã§ããªãã§ããããããå°æ¥ç¬¬1ä¸ä»£ãå»æ¢ãããæã®ç§»è¡ä½æ¥ãé¢åã«ãªããªãæ¹ãè¯ãã¨æã£ãã®ã§ã第2ä¸ä»£ãé¸æãã¾ããã
ã¨ããããé¸æåã«ã¯ç¢ºèªåºæ¥ãªãã£ããã¤ãã¼ãªè¦åã®ä¸ã«ãPHP ããã® DB æ¥ç¶ã«åé¡ããããããªè¨è¿°ããããä¸ç¬ãã¤ãã¨ãã¾ãããã¾ããçµæçã«ã¯ç¹ã«åé¡ããªã使ãã¦ããã®ã§ã第2ä¸ä»£ã§æ£è§£ã ã£ãã¨æãã¾ãã
ãã¦ãç¡äºã« WP ã®åæã¤ã³ã¹ãã¼ã«ç»é¢ã表示ãããã¾ã£ãã㪠WP ã¯åããã¨ã確èªåºæ¥ã¾ããã次ã¯ãæ¢åã® WP ã§åãã¦ãããã¼ã¿ã®ç§»è¡ä½æ¥ãè¡ã£ã¦ããã¾ãã
å®ã®ã¨ãã Cloud SQL ããèªã¿è¾¼ã¿å¯è½ãªãã¡ã¤ã«ãç½®ãå ´æã¨ããã®ãéããã¦ãã¦ãããã«ç½®ããªãéããCould SQL ã®ã¤ã³ãã¼ãç»é¢ã«ç¾ãã¾ãããAmazon ãç¥ã£ã¦ãã人ã§ããã°ãEBS ãã¤ã¡ã¼ã¸ããã¨åãããããã¨æãã¾ããAmazon ã§ã¯ EC2 ã¤ã³ã¹ã¿ã³ã¹ä¸ã«æ¸ãè¾¼ãã ãã¡ã¤ã«ã¯ã¤ã³ã¹ã¿ã³ã¹ãè½ã¨ãã¨æ¶ãã¦ãã¾ãã¾ãããGAE ã§ã¯ããããæ¸ãè¾¼ããªããã¦ãèªã¿æ¸ããããªãå¿ ããããªï¼ã¨ãã風ã«ãªã£ã¦ããã®ã§ãåãããããã¨è¨ãã°åãããããããç¥ãã¾ããã
ãã¼ã¿ã®å 容ãèªãã§ä¿®æ£ã§ããªãã試ã¿ããã®ã®ãã·ã³ãã«ãããªããã«ãä½ãåå ããæ³åãããã¨ãåºæ¥ãããã£ãã丸ãã¨å ¨é¨ç§»è¡ãããã¨ã¯è«¦ãããã¨ã«ãã¾ããã
è²ã æ¤è¨¼ããçµæããã¼ã¿ã移è¡ããæã«åé¡ãçºçããã®ã¯ wp_usersãwp_usermetaãwp_options ã® 3 ã¤ã®ãã¼ãã«ã§ããã¨åãã£ãã®ã§ãå ãã¼ã¿ã®ã®ãã³ããããããã®ãã¼ãã«ã®é¤ãã SQL ãä½ããããã©ã«ãã®ã¾ã£ãã㪠DB ã«ãã® SQL ã被ãããã¨ã§æ¨©éã®åé¡ã¯è§£æ±ºãã¾ãããwp_options ã対象ã ã£ãã®ã§ãè¨å®çã®ç§»è¡ã¯æåã§ããå¿ è¦ãããã¾ãããããããæ¸ãã æç¹ã§ã¨ããããæ°ç°å¢ã§ãã管çç»é¢ãæ£ãã使ãã¦ãæ°è¦ã®æ稿ãããããæ°è¦ã®ãã¡ã¤ã«ã¢ãããã¼ãããããããåã«ã¯åé¡ç¡ãç¶æ ã«ãªãã¾ããã
ãã¦æ¬¡ã¯ãå ã ããæ稿å 容ã§ç»åããªã³ã¯ãåãã¾ãã£ã¦ãåé¡ã解決ããªãã¨ãããªãã®ã§ãããããã¯ã¾ã次ã®ãã¹ãã§æ¸ããã¨æãã¾ãã
ã´ã¼ã«
- ãµã¼ã移è¡
- å½ããåã§ãããèªåã§æ§ç¯ããç°å¢ãã GAE ã¨ããç°å¢ã¸ã®ãµã¼ã移è¡ãè¡ããã¨ãæãéè¦ãªã´ã¼ã«ã§ãã
- URL 移è¡
- ãµã¼ãã¨ç°å¢ã®ç§»è¡ãããã«å½ãããURL ãããã¾ã§ã¨åããã®ã使ããããã«ããå¿ è¦ãããã¾ãããå¾ã£ã¦ãããã°ã®ã·ã¹ãã ã¨ãã¦ã¯ããã¾ã§ã®ãã¼ã¿ããã®ã¾ã¾ä½¿ãã WP ä¸æã«ãªãã¾ãã
- ã¨ã¯è¨ããå ã ã® www.otchy.net ãã¡ã¤ã³ã§ã¯ãç¯æãªã WP ã¨ã¯ç¡é¢ä¿ãªæã«ããã¡ã¤ã«ãå¤ãç½®ãã¦ä½¿ã£ã¦ããã®ã§ããããã«ã¤ãã¦ã¯ãªãã¤ã¬ã¯ãçãæ¤è¨ããå¿ è¦ãããã¾ããã
- ã¬ã¹ãã³ã·ã
- ã©ãããµã¼ããã·ã¹ãã ã移è¡ãããªããã¤ãã§ã«ãã¶ã¤ã³ãã¬ã¹ãã³ã·ãã«ãã¦ãä»æ´ã§ã¯ããã¾ãããã¡ããã¨ã¢ãã¤ã«å¯¾å¿ããã¨ããã®ãã´ã¼ã«ã®1ã¤ã«ãªãã¾ãã
ã§ããã以åããããã¨èª¿ã¹ãã¨ãããã¯ãå¶éãå¤ããã¼ãããããã°ãç«ã¡ä¸ãã¦ãå®å ¨ã« wordpress.com ã«ä¹ã£ããã®ã§ããã°ããªã楽ã§ã¯ãããã®ã®ãããã®ããã«ããã§ã«ã³ã³ãã³ãè³ç£ãæã£ã¦ããããå¤å°ã¯åã£ããã¨ãããããã¨æãã¨ãããªãé¢å (ãããã¯ä¸å¯è½) ã¨ããç¹ã§ãä»ã®é¸æè¢ãæ¢ãã¦ãã¾ããã
ãã®å¾ãæè¿ãã£ãããã¡ã³ã«ãªã£ã GAE 㧠WP ãåãã¨ç¥ãã¨ããã«ãªãããããªã£ãããã«ã¯ãã GAE/php 以å¤ã®é¸æè¢ã¯ããå¾ãªããã¨è¨ããã¨ã§ä»åã®ç§»è¡ä½æ¥ã«è¸ã¿åãã¾ããããã以éã§ã¯å®éã«ã©ã®ãããªä½æ¥ãè¡ã£ããé ã追ã£ã¦è§£èª¬ãã¦ãããã¨æãã¾ãã
WordPress on App Engine Starter Project
WP ã GAE ä¸ã§åããã«ããã£ã¦ãå¿ é ã¨ãªãã®ã WordPress on App Engine Starter Project ã§ãããã㯠Google ã®ä¸ã®äººãæ¸ãã GAE/php ã® WP åãã¹ã±ã«ãã³Â + WP ãã©ã°ã¤ã³ã§ãWP ã GAE ä¸ã§åããã«ããã£ã¦å¿ è¦ãªãã®ã¯åºæ¬çã«å ¨ã¦ããã«å«ã¾ãã¦ãã¾ããå ã ã® WP èªä½ãè²ã ãªã·ã¼ã³ã§ãã®ã¾ã¾ãã¼ã«ã«ãµã¼ãã«ãã¡ã¤ã«ãæ¸ãè¾¼ãã§ä½¿ããã¨ããå¾åã«ããã®ã§ãããGAE ã®ã¦ã§ããµã¼ãã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯ãä¸åã®ãã¡ã¤ã«æ¸ãè¾¼ã¿ãç¦ãããã¦ãã¦ãããããã¼ã«ã«ãã¡ã¤ã«ã«ä¾åããæ©è½ã¯ããã®ã¾ã¾ã ã¨ãã¨ãã¨ãã¨ã©ã¼ã«ãªã£ã¦ä½¿ãã¾ããã
ã¾ããGAE ã§ã¯åºæ¬çã«ãã£ã¹ã¯ã¸ã®ã¢ã¯ã»ã¹ãé«ä¾¡ã§ããããã«è¨è¨ããã¦ãã¾ããéã« memcached ã¯æ¨æºã§ä½¿ããããã«ãªã£ã¦ãã¦ã¨ã¦ãå®ä¾¡ã«è¨å®ããã¦ããã®ã§ãå¯è½ã§ããã°ãã£ã¹ã¯ã¢ã¯ã»ã¹ããªãã¹ãé¿ããããã©ãã©ããã£ãã·ã¥ã¯æ´»ç¨ãã¦ããã¹ãã§ãã
ãããæ¢åã® WP ã§ã¯å¯¾å¿ãã¦ããªãé¨åããGAE ã®ããã¼ã«åããã¦æãåºãã¦ãããã®ããã® WP ãã©ã°ã¤ã³ã§ããã¨è¨ãã¾ãã
ãã¦ãã¾ãã¯ã¾ã£ãããªç°å¢ã§ WP ãåããã¦ã¿ã¦ãã¨ããããã¡ããã¨åä½ããã¨ããäºã確ããããã£ãã®ã§ãWordPressãGAEã§ç°¡åã«ä½¿ã10ã®ã¹ããã ã大ãã«åèã«ããã¦ããã ããã»ããã¢ãããã¦ã¿ã¾ãããè¨äºãå°ãå¤ããã®ãªã®ã§ãç»é¢ã®ã¹ã¯ãªã¼ã³ã·ã§ãããªã©ä»ã®ãã¼ã¸ã§ã³ã¨ã¯ç°ãªãé¨åãå¤ã ããã¾ããããããã¯åºæ¬çã«èªã¿æ¿ãã§åé¡ç¡ãé²ããã¨ãåºæ¥ã¾ããã
ä¸ç¹å¤§ããç°ãªã£ãã®ã¯ãCloud SQL ã¤ã³ã¹ã¿ã³ã¹ã«é¢ãã¦ã®é¨åã§ããç¾å¨ã¯ãCloud SQL 第2ä¸ä»£ã¨ããé«ããã©ã¼ãã³ã¹ã謳ã£ãæ°ãã¼ã¸ã§ã³ã®å©ç¨ãæ¨å¥¨ããã¦ãã¾ããããã¯ãã¼ã¿çã¨ããæ±ãã«ãªã£ã¦ãã¦ãç¾ç¶ã§ã¯ SLA ã®ä¿è¨¼ããªãã£ããããã¤ã³ãã¤ã³ã¿ã¤ã ãªã«ã㪠(ãµã¼ãã¯ã©ãã·ã¥ç´åã¾ã§æ»ãããªã«ããª) ãåºæ¥ãªãã£ããã¨ããä¸å©ãªç¹ãããã¾ããå人ããã°ã§æ°ã«ãããã®ã§ããªãã§ããããããå°æ¥ç¬¬1ä¸ä»£ãå»æ¢ãããæã®ç§»è¡ä½æ¥ãé¢åã«ãªããªãæ¹ãè¯ãã¨æã£ãã®ã§ã第2ä¸ä»£ãé¸æãã¾ããã
ã¨ããããé¸æåã«ã¯ç¢ºèªåºæ¥ãªãã£ããã¤ãã¼ãªè¦åã®ä¸ã«ãPHP ããã® DB æ¥ç¶ã«åé¡ããããããªè¨è¿°ããããä¸ç¬ãã¤ãã¨ãã¾ãããã¾ããçµæçã«ã¯ç¹ã«åé¡ããªã使ãã¦ããã®ã§ã第2ä¸ä»£ã§æ£è§£ã ã£ãã¨æãã¾ãã
ãã¦ãç¡äºã« WP ã®åæã¤ã³ã¹ãã¼ã«ç»é¢ã表示ãããã¾ã£ãã㪠WP ã¯åããã¨ã確èªåºæ¥ã¾ããã次ã¯ãæ¢åã® WP ã§åãã¦ãããã¼ã¿ã®ç§»è¡ä½æ¥ãè¡ã£ã¦ããã¾ãã
WP ãã¼ã¿ãã¼ã¹ã®ç§»è¡
ã¨ããããä½ã¯ãã¦ãããæ¢åã® MySQL ã®ãã¼ã¿ãå ¨ã¦æ°ããç°å¢ã® Cloud SQL ã«æã£ã¦ãã¦ã¿ããã¨ã«ãã¾ããããã ã絶対ã«ãã®æ¹æ³ã¯ããã¯ãã ãã¨ç¢ºä¿¡ãæã£ã¦ã¯ãããã®ã®ãããã¨è¦ã§ã¯ã©ããã£ã¦ãã¼ã¿ãã¤ã³ãã¼ããããè¯ãã®ããåããã¾ããã§ãããã¤ã³ãã¼ãã¨ããã¡ãã¥ã¼ãé¸ãã ãããã¼ã«ã«ã®ãã¡ã¤ã«ãæå®ãããã¤ã¢ãã°ãç«ã¡ä¸ãããã¨æã£ã¦ããããè©ããããé£ãã£ãæ ¼å¥½ã§ããå®ã®ã¨ãã Cloud SQL ããèªã¿è¾¼ã¿å¯è½ãªãã¡ã¤ã«ãç½®ãå ´æã¨ããã®ãéããã¦ãã¦ãããã«ç½®ããªãéããCould SQL ã®ã¤ã³ãã¼ãç»é¢ã«ç¾ãã¾ãããAmazon ãç¥ã£ã¦ãã人ã§ããã°ãEBS ãã¤ã¡ã¼ã¸ããã¨åãããããã¨æãã¾ããAmazon ã§ã¯ EC2 ã¤ã³ã¹ã¿ã³ã¹ä¸ã«æ¸ãè¾¼ãã ãã¡ã¤ã«ã¯ã¤ã³ã¹ã¿ã³ã¹ãè½ã¨ãã¨æ¶ãã¦ãã¾ãã¾ãããGAE ã§ã¯ããããæ¸ãè¾¼ããªããã¦ãèªã¿æ¸ããããªãå¿ ããããªï¼ã¨ãã風ã«ãªã£ã¦ããã®ã§ãåãããããã¨è¨ãã°åãããããããç¥ãã¾ããã
WP ãã¼ã¿ã®ä¿®æ£
WP ã®ãã¼ã¿ãã¼ã¹ã丸ãã¨ç§»è¡ãããã¨ã§ãããããã£ã¦åè¨äºã¯å ã¨åã URL (ãã®æç¹ã§ã¯ç°ãªãä»®ãã¡ã¤ã³ä¸ã®åãç¸å¯¾ãã¹) ã§è¡¨ç¤ºãããããã«ãªã£ããã®ã®ãç»åãã¡ã¤ã«ã®ãã¹ãªã©ã¯ãã¨ãã¨ãåãã¦ãã¦ããããã£ã½ä½ã表示ãããªãç¶æ ã§ããããããããããã«å°ã£ããã¨ã«ãWP ã®ãã¼ã¸ã§ã³ã®éãã«ããå½±é¿ããWP ã¢ã«ã¦ã³ãã®ãã°ã¤ã³æ å ±ãæ£ããåä½ãã¦ããããå ã®ãã¼ã¿ã®ç®¡çè ã¢ã«ã¦ã³ãã§ãã°ã¤ã³ã¯åºæ¥ããã®ã®ãä½ã®æ¨©éããªã管çç»é¢ãéããªããã¨ããç¶æ ã§ããããã¼ã¿ã®å 容ãèªãã§ä¿®æ£ã§ããªãã試ã¿ããã®ã®ãã·ã³ãã«ãããªããã«ãä½ãåå ããæ³åãããã¨ãåºæ¥ãããã£ãã丸ãã¨å ¨é¨ç§»è¡ãããã¨ã¯è«¦ãããã¨ã«ãã¾ããã
è²ã æ¤è¨¼ããçµæããã¼ã¿ã移è¡ããæã«åé¡ãçºçããã®ã¯ wp_usersãwp_usermetaãwp_options ã® 3 ã¤ã®ãã¼ãã«ã§ããã¨åãã£ãã®ã§ãå ãã¼ã¿ã®ã®ãã³ããããããã®ãã¼ãã«ã®é¤ãã SQL ãä½ããããã©ã«ãã®ã¾ã£ãã㪠DB ã«ãã® SQL ã被ãããã¨ã§æ¨©éã®åé¡ã¯è§£æ±ºãã¾ãããwp_options ã対象ã ã£ãã®ã§ãè¨å®çã®ç§»è¡ã¯æåã§ããå¿ è¦ãããã¾ãããããããæ¸ãã æç¹ã§ã¨ããããæ°ç°å¢ã§ãã管çç»é¢ãæ£ãã使ãã¦ãæ°è¦ã®æ稿ãããããæ°è¦ã®ãã¡ã¤ã«ã¢ãããã¼ãããããããåã«ã¯åé¡ç¡ãç¶æ ã«ãªãã¾ããã
ãã¦æ¬¡ã¯ãå ã ããæ稿å 容ã§ç»åããªã³ã¯ãåãã¾ãã£ã¦ãåé¡ã解決ããªãã¨ãããªãã®ã§ãããããã¯ã¾ã次ã®ãã¹ãã§æ¸ããã¨æãã¾ãã
ã«ãã´ãª: Development ã¿ã°: gae