FastCGIç°å¢ãæ§ç¯ãã
é·ããPHPå±ããã£ã¦ããã®ã§ãã£ã¨mod_phpã ã£ããã ãã©ããã¤ãã¯FastCGIããããã¨ãªãã¨æã£ã¦ããã¨ããã«ãå æ¥Tracã§mod_fcgidãå°å ¥ããã®ã§ãããããã¦ã¿ãã
以ä¸ã¯ã°ã°ã£ã¦èªåãªãã«ã¾ã¨ãããã®ãªã®ã§ãèªèãééã£ã¦ãããã®ããããããããªãã®ã§æ³¨æã
FastCGIã®ã¡ãªãã
- CGIããã°ã©ã ã®ããã»ã¹ã常é§ãã
- ããã°ã©ã ã®èµ·åãªã¼ãã¼ãããããªã
- ãã¼ã¿ããªã½ã¼ã¹ãã¡ã¢ãªä¸ã§æ°¸ç¶åã§ããï¼DBã³ãã¯ã·ã§ã³ã¨ãï¼
- Webãµã¼ãã«ä¾åããªã
- å
¬éããããããã³ã«
- FastCGI対å¿ãµã¼ããªãã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯åã
- Webãµã¼ãã¨ç¬ç«ããããã»ã¹ã§åã*1
- å®å®ï¼ããã»ã¹çãªæå³ã§ï¼
- ã»ãã¥ã¢ï¼ããã»ã¹çãªï¼ï½ï½ï¼
- Webãµã¼ãã太ããªãï¼å¦çç³»ã®ã¢ã¸ã¥ã¼ã«ããã¼ãããªãã¦ããããï¼
- ãã©ã³ã·ã³ã°ãåæ£ããããããï¼Webãµã¼ãã¨CGIããã°ã©ã ãå¥ã ã®ãµã¼ãã«ã§ããï¼
- è¨èªå¦çç³»ã«åé¡ããã£ã¦ã¹ã¬ããåã®MPMã使ããªãåé¡ã解æ¶ã§ãããããããªã
- å
¬éããããããã³ã«
- suEXECã§ããã£ã½ãï¼æªèª¿æ»ãforkã¿ã¤ãã ã¨ç¡çï¼ï¼
- ã¦ã¼ã¶æ¯ã«ããã»ã¹ãå¿ è¦ãããï¼å½ç¶ãï¼
FastCGIã®ãã¡ãªãã
- ããã°ã©ã ãFastCGIç¨ã«æ¸ããªããã°ãããªã
- ã©ãããä½æ³ã«ãªããã¯è¨èªã«ããï¼ãã®ã¾ã¾åä½ããè¨èªãããï¼
- ã©ããã¼ãå©ç¨ããã¨é常ã®CGIããã°ã©ã ããã®ã¾ã¾å®è¡ã§ãã
- FCGIWrapper(mod_fcgid)
- ããã°ã©ã ãæ´æ°ãã¦ãåæ ãããªãå ´åããã
- ããã»ã¹ã常é§ããã¾ã¾ãªã®ã§åèµ·åããå¿ è¦ããã
- è¨èªã«ãã£ã¦ã¾ã¡ã¾ã¡ï¼åæ ãããããããªããã¤ã³ã¯ã«ã¼ãé¡ã ãåæ ãããªãããªã©ï¼
- ãªã½ã¼ã¹ãªã¼ã¯ã«ãããä¸å±¤æ³¨æãæããªããã°ãããªã
- ãã³ãã«
- ã°ãã¼ãã«å¤æ°
- ã°ãã¼ãã«å¤æ°ã®æ示çãªåæåãå¿
è¦
- 以åã®å¤ãæ®ã£ã¦ãã*2
- å®è¡æã®ç°å¢ãªã©ã®èéãå©ããªã
- ç°å¢å¤æ°
- å®è¡æã®ç¹å¥ãªåæåå¦çï¼ã©ã¤ãã©ãªã®ãã¼ãæã®ã¿ã«èµ°ãå¦çãªã©ï¼
Apacheã§FastCGIãå©ç¨ããã«ã¯
Apacheã§FastCGIãå©ç¨ããå ´åã¯ã次ã®ä¸ç¨®é¡ã®ã¢ã¸ã¥ã¼ã«ãããã
ç¾å¨ã®ä¸»æµã¯mod_fcgidã£ã½ãã
mod_proxy_fcgiã¯mod_proxyã¿ãããªæãã§ããã¯ã¨ã³ãã®FastCGIã¨éä¿¡ããã¿ã¤ãã®ããã ï¼AJPã¨ãã®ã¤ã¡ã¼ã¸ï¼ãã¾ã è¥ãï¼
åè
ï¼ã¤ãforkãªã®ã«å¯¾ãã¦ãå¾è
ã¯å®å
¨ã«ç¬ç«ããFastCGIããã»ã¹ã¨éä¿¡ï¼TCPã¾ãã¯ã½ã±ããï¼ãã¦å¦çãããã®ã«ãªãããã ããããããFastCGIã®çã®å§¿ãªãã ãããã
mod_fcgidãå ¥ãã¦ã¿ã
Ubuntuã®å ´åã
sudo apt-get install libapache2_mod_fcgid sudo a2enmod fcgid
ããã ãï¼ã©ããã®é¤æ²¹ã®CMã¿ããã ï¼ã
è¨å®ãã¡ã¤ã«ã¯/etc/apache2/mods-available/fcgid.conf
æä½ã§ãhttp://fastcgi.coremail.cn/doc.htmãè¦ã¦ãMaxProcessCountãDefaultMinClassProcessCountãDefaultMaxClassProcessCountãããã¯èª¿æ´ãã¦ãããããã¤ãã§ã«Apache MPMã®ã»ãã調æ´ãã¦ãããã»ããããã
ãã®è¾ºããã£ãã調æ´ããªãã¨å¦çããã°ããããªãã¦ãªã¯ã¨ã¹ãã失æããããã«ãªãã
ãã¹ã¯ãããPCã®ãã¼ãã£ã«ãã·ã³ã¿ãããªãªã½ã¼ã¹ã®ä¹ããç°å¢ã§ããã¹ããã¦ãã«abã§ãåãããã®ãªã大å¤ãªãã¨ã«ãªãã
PHPãFastCGIã§åãã
PHPã¯ä»ã®è¨èªã¨ã¯å°ãéã£ãåããããããã ã
å¤ãã®è¨èªãã³ã³ãã¤ã«æ¸ã¿ããã°ã©ã ããã®ã¾ã¾ããã»ã¹ã«æ®ãã®ã«å¯¾ããPHPã¯ã¤ã³ã¿ããªã¿ã ããæ®ãã¦ã¹ã¯ãªããèªä½ã¯æ¯åã³ã³ãã¤ã«ããããã*3ã
æ¯åã³ã³ãã¤ã«ãããªã¼ãã¼ããããçãããã©ãåé¢ã¹ã¯ãªãããã¡ã¤ã«ãæ¸ãæããã¨å³åº§ã«åæ ããããã¨ã«ãªããä»ã®è¨èªã®å ´åã¯ããã»ã¹ãåèµ·åããå¿
è¦ãããããmod_fcgidã®å ´åãã¤ã¾ãã¨ããApacheãåèµ·åãããã¨ã«ãªãã®ã§çµæ§çãã
PHPã¯mod_phpã®ä½¿ãåæãã®ã¾ã¾ã¨ããæãã*4ãã¨ãããPHPã«ãããFastCGIã¯mod_phpã¨å¤§å·®ãªãæ°ããã¦ããã
è¨å®ã«ã¯ä¸å·¥å¤«å¿ è¦ã§ãFCGIWrapperã«CGIçã®PHPã¤ã³ã¿ããªã¿ãæå®ããã
<Directory /var/www/php-fcgi> AddHandler fcgid-script .php FCGIWrapper /usr/bin/php-cgi .php Options +ExecCGI </Directory>
ã¹ã¯ãªãããã¡ã¤ã«å´ã¯Shebangï¼#!/usr/bin/phpã¨ããããã¤ï¼ã¯å¿
è¦ãªããã¨ãããä»ããã¨ãã®ã¾ã¾åºåãããã£ã½ãã
ãã ããã¼ããã·ã§ã³ã¯å®è¡æ¨©éãä»ãã¦ããå¿
è¦ãããã
ãã®ä»ã®ãã¨
SpeedyCGIã¨ãã
*1:ãã ãå®ç¾æ¹æ³ã«ãã£ã¦ã¯ãµã¼ãã®åããã»ã¹ãªã®ã§ã親ãæ»ã¬ã¨ä¸ç·ã«æ»ã¬ã
*2:ã¨ãããããã°ã©ã ãåå®è¡ããã¦ããããããªãã®ã§ã
*3:FCGIWrapperã使ããªããã°ä»ã®è¨èªã¨åããããªåãã«ãªããããªæ°ãããã
*4:ã¨ãããä»ã®è¨èªã¯mod_hogehogeã§ãåèªè¾¼ãã¦ãããªãããã