{"id":1465,"date":"2008-11-16T14:46:00","date_gmt":"2008-11-16T05:46:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=187"},"modified":"2008-11-16T14:46:00","modified_gmt":"2008-11-16T05:46:00","slug":"blogn-187","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=187","title":{"rendered":"CGI\u306f\u3058\u3081\u307e\u3057\u305f\u3068\u3044\u3046\u304b\u3089\u8a66\u3057\u305f"},"content":{"rendered":"<p>\u90e8\u306eWeb\u30b5\u30fc\u30d0\u30fc\u3067CGI\u52d5\u304b\u3057\u305f\u3044\u3068\u304b\u3044\u3046\u8981\u671b\u304c\u3042\u3063\u305f\u305d\u3046\u3060\u3002<br \/>\u305d\u308c\u3067\u7ba1\u7406\u8005\u304chttpd.conf\u3044\u3058\u3063\u3066\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u304c\u3001<br \/>\u3046\u307e\u304f\u52d5\u304b\u306a\u3044\u3068\u304b\u8a00\u3046\u306e\u3067\u3001\u898b\u3066\u3044\u305f\u3002<br \/>\u3069\u3046\u3082\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u65b9\u304c\u304a\u304b\u3057\u304b\u3063\u305f\u3089\u3057\u3044\u3002<br \/>\u305d\u306e\u5f8c\u7d30\u304b\u3044\u8a2d\u5b9a\u3092\u3057\u3066\u5b8c\u6210\u3068\u76f8\u6210\u3063\u305f\u305d\u3046\u3060\u3002<\/p>\n<hr \/>\n<p>\u5b9f\u306f\u50d5\u306fCGI\u3092\u4f7f\u3063\u305f\u3053\u3068\u306a\u304b\u3063\u305f\u306e\u3088\u306d\u3002<br \/>\u305d\u3082\u305d\u3082CGI\u3068\u3044\u3046\u306e\u306fCommon Gateway Interface\u3068\u3044\u3046\u4ed5\u7d44\u307f\u306e\u3053\u3068\u3092\u8a00\u3046\u3002<br \/>\u307e\u3041\u304a\u7d04\u675f\u306b\u5f93\u3063\u3066\u66f8\u304b\u308c\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092Apache\u306a\u3069\u304c\u52d5\u4f5c\u3055\u305b\u3066\u304f\u308c\u308b\u3068\u3002<br \/>\u305d\u3046\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\u3068\u3053\u308d\u3067PHP\u306f\u666e\u901amod_php5\u3092Apache\u306b\u8aad\u307f\u8fbc\u307e\u305b\u3066\u4f7f\u3046\u3002<br \/>\u3059\u306a\u308f\u3061Apache\u3092PHP\u306e\u51e6\u7406\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u62e1\u5f35\u3055\u305b\u3066\u3001Apache\u306b\u51e6\u7406\u3057\u3066\u3082\u3089\u3046\u3068\u3002<br \/>\u3060\u304b\u3089Apache\u304c\u7acb\u3061\u4e0a\u304c\u3063\u3066\u3057\u307e\u3048\u3070\u3001PHP\u306e\u51e6\u7406\u306f\u9ad8\u901f\u3068\u3044\u3046\u3053\u3068\u3002<br \/>\u4e00\u65b9\u3067\u306f\u5168\u3066root\u6a29\u9650\u3067\u5b9f\u884c\u3055\u305b\u308b\u304b\u3089\u5371\u967a\u304b\u3082\u3068\u3044\u3046\u306e\u306f\u3042\u308b\u3002<br \/>\u3053\u306e\u4ed5\u7d44\u307f\u3067\u52d5\u4f5c\u3059\u308b\u306e\u306fPHP\u304c\u3082\u3063\u3068\u3082\u6709\u540d\u3067\u3059\u306d\u3002<br \/>\u3042\u3068mod_ruby\u3068\u304b\u3002<\/p>\n<hr \/>\n<p>CGI\u3060\u304c\u2026\u307e\u3041\u4f8b\u3092\u793a\u3059\u306e\u304c\u65e9\u3044\u304b\u306a\u3002<\/p>\n<pre>#!\/usr\/bin\/php<br \/>Content-type: text\/plain<br \/><br \/>&lt;?php phpinfo(); ?&gt;<\/pre>\n<p>\u308f\u3056\u308f\u3056CGI\u3092PHP\u3067\u66f8\u304f\u3042\u305f\u308a\u304c\u4e0d\u6c17\u5473\u3067\u3059\u306d\u3002<br \/>\u307e\u3041\u3068\u308a\u3042\u3048\u305a\u3053\u308c\u306b\u5b9f\u884c\u6a29\u3092\u4e0e\u3048\u3066\u3001<br \/>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u52d5\u4f5c\u3059\u308b\u304b\u78ba\u304b\u3081\u3066\u307f\u308b\u3002PHP\u304c\u52d5\u4f5c\u3059\u308b\u306a\u3089\u3001\u52d5\u4f5c\u3057\u307e\u3059\u306d\u3002<br \/>\u305d\u3057\u3066\u3053\u308c\u3092foo.cgi\u3068\u304b\u3057\u3066\u4fdd\u5b58\u3059\u308b\u3002\u305d\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3002<br \/>\u3046\u307e\u304f\u52d5\u304f\u3093\u3058\u3083\u306a\u3044\u304b\u306a?<br \/>CGI\u3068\u3044\u3046\u306e\u306f\u3001\u52d5\u4f5c\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3001\u307e\u305a\u30d8\u30c3\u30c0\u30fc\u3092\u51fa\u529b\u3057\u3066\u3001\u3053\u308c\u306b\u7d9a\u3051\u3066\u5185\u5bb9\u3092\u66f8\u304d\u51fa\u3059\u3068\u3002<br \/>\u3058\u3083\u3042\u3001\u3068\u3044\u3046\u308f\u3051\u3067\u3053\u3046\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n<pre>#include &lt;stdio.h&gt;<br \/>main(){<br \/>  int i;<br \/>  fputs(\"Content-type: text\/plain\\n\\n\",stdout);<br \/>  for(i=1;i&lt;=100;i++){<br \/>    printf(\"%d\\n\",i);<br \/>  }<br \/>}<\/pre>\n<p>\u3053\u308c\u3092gcc -o ccgi.cgi ccgi.c\u3068\u304b\u3059\u308c\u3070\u5b8c\u6210\u3002<br \/>\u666e\u901a\u306b\u52d5\u304d\u307e\u3059\u3088\u3002\u3068\u3044\u3046\u308f\u3051\u3067\u3069\u3046\u3082\u3053\u3046\u3044\u3046\u3082\u306e\u3089\u3057\u3044\u3067\u3059\u3002<\/p>\n<hr \/>\n<p>\u305f\u3060\u521d\u3081\u306e\u30d8\u30c3\u30c0\u30fc\u306b\u3057\u3066\u3082\u3001\u307e\u3041CGI\u306b\u7279\u306b\u5fc5\u8981\u306a\u3053\u3068\u3082\u591a\u3044\u3068\u3002<br \/>\u3060\u304b\u3089CGI\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308a\u307e\u3059\u306d\u3002<br \/>\u3061\u306a\u307f\u306bPHP\u3060\u304c\u3001\u57fa\u672c\u7684\u306b\u306f\u7d44\u307f\u8fbc\u307f\u52d5\u4f5c\u3067\u3082CGI\u52d5\u4f5c\u3067\u3082\u5909\u308f\u3089\u306a\u3044\u3002<br \/>\u3055\u3063\u304d\u306f\u8aac\u660e\u306e\u305f\u3081\u306b\u624b\u52d5\u3067\u66f8\u3044\u305f\u304c\u3001\u3053\u308c\u306f\u666e\u901a\u3058\u3083\u306a\u3044\u3002<br \/>#!\/usr\/bin\/php-cgi\u3068\u3059\u308c\u3070\u4e00\u822c\u7684\u306aPHP\u3092CGI\u52d5\u4f5c\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<br \/>\u307e\u3041\u2026php.ini\u306e\u8a2d\u5b9a\u3092\u3057\u306a\u3044\u3068\u5f3e\u304b\u308c\u307e\u3059\u304c\u3002<br \/>\u3042\u3068PHP\u3092\u7d44\u307f\u8fbc\u307f\u3067\u52d5\u4f5c\u3055\u305b\u308b\u306a\u3089\u5b9f\u884c\u6a29\u3044\u3089\u3093\u3051\u3069\u3001CGI\u306e\u5834\u5408\u5fc5\u8981\u3060\u3063\u305f\u308a\u3059\u308b\u306e\u3067\u6ce8\u610f\u3002<br \/>\u8a2d\u5b9a\u3082\u305d\u3093\u306a\u306b\u8907\u96d1\u3058\u3083\u306a\u3044\u304b\u3089Libserver\u3067\u3082CGI\u53ef\u306b\u3057\u3066\u3044\u3044\u304b\u306a\u3068\u304b\u3002<br \/>Option +CGIExec \u3068\u3059\u308b\u3060\u3051\u3060\u3057\u3002<br \/>\u3051\u3069\u52d5\u304b\u3057\u305f\u3044\u30b9\u30af\u30ea\u30d7\u30c8\u3082\u306a\u3044\u304b\u3089\u3044\u3044\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u90e8\u306eWeb\u30b5\u30fc\u30d0\u30fc\u3067CGI\u52d5\u304b\u3057\u305f\u3044\u3068\u304b\u3044\u3046\u8981\u671b\u304c\u3042\u3063\u305f\u305d\u3046\u3060\u3002\u305d\u308c\u3067\u7ba1\u7406\u8005\u304chttpd.conf\u3044\u3058\u3063\u3066\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u304c\u3001\u3046\u307e\u304f\u52d5\u304b\u306a\u3044\u3068\u304b\u8a00\u3046\u306e\u3067\u3001\u898b\u3066\u3044\u305f\u3002\u3069\u3046\u3082\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u65b9\u304c\u304a\u304b\u3057\u304b\u3063\u305f\u3089\u3057\u3044\u3002\u305d\u306e\u5f8c\u7d30\u304b\u3044 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1465","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1465"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1465\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}