﻿{"id":950,"date":"2014-06-06T10:59:27","date_gmt":"2014-06-06T02:59:27","guid":{"rendered":"http:\/\/notes.zerobox.org\/?p=950"},"modified":"2014-06-06T10:59:28","modified_gmt":"2014-06-06T02:59:28","slug":"%e7%94%a8perl%e7%bc%96%e5%86%99apache%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"http:\/\/zerobox.org\/notes\/950.html","title":{"rendered":"\u7528Perl\u7f16\u5199Apache\u6a21\u5757"},"content":{"rendered":"<div id=\"cnblogs_post_body\" style=\"color: #000000;\">\n<h2><span class=\"application\">\u524d\u8a00<\/span><\/h2>\n<p><span class=\"application\">Apache\u88ab\u8bb8\u591a\u5927\u6d41\u91cf\u7f51\u7ad9\u6240\u5acc\u5f03\uff0c\u4f46\u5f88\u591a\u4f01\u4e1a\u7ea7\u7684\u573a\u666f\u5219\u66f4\u4e3a\u9002\u7528\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"application\">Apache httpd \u4ece 2.0 \u4e4b\u540e\uff0c\u5df2\u7ecf\u4e0d\u4ec5\u4ec5\u5c40\u9650\u4e8e\u4e00\u4e2a http \u7684\u670d\u52a1\u5668\uff0c\u66f4\u662f\u4e00\u4e2a\u5b8c\u5584\u800c\u5f3a\u5927\u3001\u7075\u6d3b\u800c\u5065\u58ee\u4e14\u5bb9\u6613\u6269\u5c55\u7684\u5f00\u53d1\u5e73\u53f0\u3002<\/span><\/p>\n<p><span class=\"application\">\u5f00\u53d1\u4eba\u5458\u901a\u8fc7\u5b9a\u5236 Apache \u6a21\u5757\uff0c\u53ef\u4ee5\u51e0\u4e4e\u65e0\u9650\u5236\u7684\u6269\u5c55 Apache httpd\uff0c\u4f7f\u5176\u66f4\u597d\u7684\u4e0e\u5b9e\u9645\u5e94\u7528\u573a\u666f\u5339\u914d\uff0c\u800c\u53c8\u65e0\u9700\u8003\u8651\u5e95\u5c42\u7684\u7f51\u7edc\u4f20\u8f93\u7ec6\u8282\u3002\u8fd9\u6837\u65e2\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u8282\u7701\u5f00\u53d1\u6210\u672c\uff0c\u53c8\u80fd\u5145\u5206\u5229\u7528 Apache \u672c\u8eab\u7684\u5065\u58ee\u6027\u53ca\u53ef\u9760\u6027\u3002<\/span><\/p>\n<p><span class=\"application\">\u666e\u904d\u610f\u4e49\u4e0a\u7684\u7406\u89e3\uff0cApache\u7684\u6a21\u5757\u5f00\u53d1\uff0c\u5206\u4e3a\u4e24\u79cd\u9014\u5f84\uff1aC\u3001Perl\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"application\">Apache<\/span>\/Perl \u96c6\u6210\u8ba1\u5212\uff0c \u5c06 Perl \u7a0b\u5e8f\u8bbe\u8ba1\u8bed\u8a00\u7684\u5f3a\u5927\u529f\u80fd\uff0c \u4e0e\u00a0<span class=\"application\">Apache HTTP \u670d\u52a1\u5668<\/span>\u00a0\u7d27\u5bc6\u5730\u7ed3\u5408\u5230\u4e86\u4e00\u8d77\u3002 \u901a\u8fc7\u00a0<span class=\"application\">mod_perl<\/span>\u00a0\u6a21\u5757\uff0c \u53ef\u4ee5\u5b8c\u5168\u4f7f\u7528 Perl \u6765\u64b0\u5199\u00a0<span class=\"application\">Apache<\/span>\u00a0\u6a21\u5757\u3002 \u6b64\u5916\uff0c \u670d\u52a1\u5668\u4e2d\u5d4c\u5165\u7684\u6301\u4e45\u6027\u89e3\u91ca\u5668\uff0c \u6d88\u9664\u4e86\u7531\u4e8e\u542f\u52a8\u5916\u90e8\u7684\u89e3\u91ca\u5668\u4e3a Perl \u811a\u672c\u7684\u542f\u52a8\u6240\u9020\u6210\u7684\u6027\u80fd\u635f\u5931\uff0c\u7f16\u7801\u96be\u5ea6\u4e0e\u666e\u901aCGI\u57fa\u672c\u76f8\u540c\uff0c\u8fd0 \u884c\u901f\u5ea6\u4ec5\u6bd4API\u00a0C\u7565\u900a\u4e00\u4e9b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>MOD_PERL\u6280\u672f\u7684\u4ecb\u7ecd<\/h2>\n<p>MOD_PERL\u6280\u672f\u5c06PERL\u89e3\u6790\u5668\u7f16\u8bd1\u5230APACHE\u670d\u52a1\u5668\u4e2d\u4e00\u8d77\u7b49\u5f85\u5ba2\u6237\u7aef\u8bf7\u6c42\u3002<br \/>\nMOD_PERL\u6280\u672f\u5728APACHE\u4e2d\u4e00\u5171\u6709\u4e09\u79cd\u4ee3\u7801\u8fd0\u884c\u65b9\u5f0f\uff1a<br \/>\nPerlRun\u6a21\u5f0f\uff1a\u8fd9\u4e2a\u6a21\u5f0f\u4e3b\u8981\u517c\u5bb9\u65e7\u5f0fCGI\u7a0b\u5e8f\uff0c\u4ec5\u4ec5\u4f7f\u7528APACHE\u4e2d\u7684PERL\u89e3\u6790\u5668\u5bf9\u4ee3\u7801\u8fdb\u884c\u89e3\u6790\u4e0d\u8fdb\u884c\u7f13\u51b2\u3002<br \/>\nRegistry\u6a21\u5f0f\uff1a\u8fd9\u4e2a\u6a21\u5f0f\u7684Perl\u4ee3\u7801\u5728\u88ab\u8bbf\u95ee\u8fc7\u4ee5\u540e\u4f1a\u88ab\u7f16\u8bd1\u6210\u4e3aAPACHE\u00a0API\u6a21\u5757\u5e76\u4e14\u5b58\u50a8\u5728\u7f13\u51b2\u4e4b\u4e2d\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u8fd0\u884cAPACHE\u4f1a\u9009\u62e9\u6027\u7684\u4ea7\u751f\u3001\u4e0d\u53ea\u4e00\u4e2a\u526f\u672c\u5728\u5185\u5b58\u4e2d\u3002<br \/>\nAPACHE\u00a0API\u6a21\u5f0f\uff1a\u8fd9\u4e2a\u6a21\u5f0f\u5728APACHE\u542f\u52a8\u7684\u65f6\u5019\u5c31\u76f4\u63a5\u5c06\u4ee3\u7801\u7f16\u8bd1\u9a7b\u7559\u5728\u7f13\u51b2\u4e4b\u4e2d\u3002<\/p>\n<p>\u914d\u7f6e\u5b8cApache\u548cPerl\u6a21\u5757\u540e\uff0c\u53ef\u4ee5\u7528perlinfo\u51fd\u6570\u67e5\u770b\u7cfb\u7edf\u73af\u5883\u76f8\u5173\u53d8\u91cf\u3002\u4e0b\u56fe\u662f\u5728\u865a\u62df\u673a\u4e2d\u8dd1\u51fa\u6765\u7684\u6548\u679c\uff0c\u7528\u7684\u662fXAMPP\u5957\u4ef6\u7684\u8001\u7248\u672c\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/notes.zerobox.org\/wp-content\/uploads\/2014\/06\/2e4eaac5947902def516c001372316e6.png\" alt=\"\" \/><\/p>\n<p>\u770b\u5230\u8fd9\u56fe\uff0c\u60a8\u6709\u4f55\u611f\u60f3\uff1f\u662f\u4e0d\u662f\u89c9\u5f97\u592a\u50cfphpinfo\u4e86\uff0c\u4e0d\uff01\u662fphpinfo\u592a\u50cf\u4ed6\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u7f16\u5199APACHE\u6a21\u5757\u4ee3\u7801<\/h2>\n<p>example.pm\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<div class=\"cnblogs_code_toolbar\"><span class=\"cnblogs_code_copy\"><a style=\"color: #3b5999;\" title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/notes.zerobox.org\/wp-content\/uploads\/2014\/06\/9148256b89e79e5d03bf03a93cf12ac4.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/span><\/div>\n<pre><span style=\"color: #0000ff;\">package<\/span><span style=\"color: #000000;\"> example;\r\n\r\n<\/span><span style=\"color: #0000ff;\">use<\/span><span style=\"color: #000000;\"> strict;\r\n<\/span><span style=\"color: #0000ff;\">use<\/span> Apache::<span style=\"color: #000000;\">Request;\r\n<\/span><span style=\"color: #0000ff;\">use<\/span> Apache::Constants qw(:<span style=\"color: #000000;\">common);\r\n\r\n<\/span><span style=\"color: #0000ff;\">sub<\/span><span style=\"color: #000000;\"> handler {\r\n  <\/span><span style=\"color: #0000ff;\">my<\/span> <span style=\"color: #800080;\">$r<\/span> = <span style=\"color: #0000ff;\">shift<\/span><span style=\"color: #000000;\">;\r\n  <\/span><span style=\"color: #0000ff;\">my<\/span> <span style=\"color: #800080;\">$req<\/span> = Apache::Request-&gt;new(<span style=\"color: #800080;\">$r<\/span><span style=\"color: #000000;\">);\r\n\r\n  <\/span><span style=\"color: #800080;\">$req<\/span>-&gt;send_http_header(<span style=\"font-weight: bold; color: #000000;\">'<\/span><span style=\"font-weight: bold; color: #000000;\">text\/html<\/span><span style=\"font-weight: bold; color: #000000;\">'<\/span><span style=\"color: #000000;\">);\r\n  <\/span><span style=\"color: #800080;\">$req<\/span>-&gt;<span style=\"color: #0000ff;\">print<\/span>(<span style=\"font-weight: bold; color: #000000;\">'<\/span><span style=\"font-weight: bold; color: #000000;\">Hello World!<\/span><span style=\"font-weight: bold; color: #000000;\">'<\/span><span style=\"color: #000000;\">);\r\n\r\n<\/span><span style=\"color: #0000ff;\">return<\/span><span style=\"color: #000000;\"> OK;\r\n} <\/span><\/pre>\n<div class=\"cnblogs_code_toolbar\"><span class=\"cnblogs_code_copy\"><a style=\"color: #3b5999;\" title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/notes.zerobox.org\/wp-content\/uploads\/2014\/06\/9148256b89e79e5d03bf03a93cf12ac4.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/span><\/div>\n<\/div>\n<p>&nbsp;<br \/>\n\u5728HTTPD.CONF\u91cc\u505a\u4ee5\u4e0b\u8bbe\u7f6e\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre>PerlModule example<span style=\"color: #008000;\">;\r\n<\/span>&lt;LocationMatch \"(service)$\"<span style=\"color: #000000;\">&gt;\r\n        SetHandler perl-script\r\n        PerlHandler example\r\n&lt;\/LocationMatch&gt; <\/span><\/pre>\n<\/div>\n<p>&nbsp;<br \/>\n\u8fd9\u6837\u5f53\u7528\u6237\u8bbf\u95eehttp:\/\/yourhost\/service\u7684\u65f6\u5019\u4f1a\u88ab\u8fd9\u4e2aAPACHE\u6a21\u5757\u5904\u7406\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u6709\u4ec0\u4e48\u7528<\/h2>\n<p>\u5176\u5b9e\u8fd9\u4e2a\u8bdd\u9898\u662f\u63a5\u7eed\u4e0a\u7bc7\u6587\u7ae0 svn\u4ee3\u7801\u7248\u672c\u7ba1\u7406\u5de5\u5177\u7684\uff0c\u5229\u7528mod_perl \u53ef\u4ee5\u7f16\u5199apache\u6a21\u5757\u6765\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684authn\u4e0eauthz\u6a21\u5757\uff0c\u4ee5\u5b9e\u73b0\u7b26\u5408\u5b9e\u9645\u60c5\u51b5\u7684\u9274\u6743\u529f\u80fd\u3002<\/p>\n<\/div>\n<div id=\"MySignature\" style=\"color: #000000;\">\u672c\u6587\u6765\u6e90\uff1ahttp:\/\/www.cnblogs.com\/x3d\/<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 Apache\u88ab\u8bb8\u591a\u5927\u6d41\u91cf\u7f51\u7ad9\u6240\u5acc\u5f03\uff0c\u4f46\u5f88\u591a\u4f01\u4e1a\u7ea7\u7684\u573a\u666f\u5219\u66f4\u4e3a\u9002\u7528\u3002 &#038;nb &hellip;<\/p>\n<p class=\"read-more\"><a href=\"http:\/\/zerobox.org\/notes\/950.html\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[229],"class_list":["post-950","post","type-post","status-publish","format-standard","hentry","tag-perl"],"views":442,"_links":{"self":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/comments?post=950"}],"version-history":[{"count":0,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/950\/revisions"}],"wp:attachment":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/media?parent=950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/categories?post=950"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/tags?post=950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}