{"id":33490,"date":"2024-09-30T01:08:21","date_gmt":"2024-09-29T17:08:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/33490\/"},"modified":"2024-09-30T01:08:21","modified_gmt":"2024-09-29T17:08:21","slug":"apache%e6%8c%87%e4%bb%a4%ef%bc%9amod_actions-%e6%93%8d%e4%bd%9c%e6%a8%a1%e7%b5%84","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/33490\/","title":{"rendered":"Apache\u6307\u4ee4\uff1amod_actions (\u64cd\u4f5c\u6a21\u7d44)"},"content":{"rendered":"<h1 id=\"apache%e6%8c%87%e4%bb%a4%ef%bc%9amod_actions-%e6%93%8d%e4%bd%9c%e6%a8%a1%e7%b5%84-yCWJZvpkNJ\">Apache\u6307\u4ee4\uff1amod_actions (\u64cd\u4f5c\u6a21\u7d44)<\/h1>\n<p>\u5728\u7db2\u9801\u4f3a\u670d\u5668\u7684\u904b\u884c\u4e2d\uff0cApache HTTP Server \u662f\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u958b\u6e90\u4f3a\u670d\u5668\uff0c\u5176\u6a21\u7d44\u5316\u7684\u67b6\u69cb\u4f7f\u5f97\u7528\u6236\u80fd\u5920\u6839\u64da\u9700\u6c42\u64f4\u5c55\u5176\u529f\u80fd\u3002\u5176\u4e2d\uff0cmod_actions \u6a21\u7d44\u662f\u4e00\u500b\u91cd\u8981\u7684\u7d44\u4ef6\uff0c\u5c08\u9580\u7528\u65bc\u8655\u7406 HTTP \u8acb\u6c42\u7684\u52d5\u4f5c\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e mod_actions \u7684\u529f\u80fd\u3001\u914d\u7f6e\u65b9\u6cd5\u53ca\u5176\u61c9\u7528\u7bc4\u4f8b\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-mod_actions%ef%bc%9f-yCWJZvpkNJ\">\u4ec0\u9ebc\u662f mod_actions\uff1f<\/h2>\n<p>mod_actions \u662f Apache \u7684\u4e00\u500b\u6a21\u7d44\uff0c\u4e3b\u8981\u7528\u65bc\u6839\u64da\u8acb\u6c42\u7684\u5167\u5bb9\u4f86\u57f7\u884c\u7279\u5b9a\u7684\u52d5\u4f5c\u3002\u9019\u4e9b\u52d5\u4f5c\u53ef\u4ee5\u662f\u57f7\u884c CGI \u8173\u672c\u3001\u91cd\u5b9a\u5411\u8acb\u6c42\u6216\u662f\u8fd4\u56de\u7279\u5b9a\u7684 HTTP \u97ff\u61c9\u3002\u901a\u904e\u9019\u500b\u6a21\u7d44\uff0c\u7ba1\u7406\u54e1\u53ef\u4ee5\u9748\u6d3b\u5730\u63a7\u5236\u4f3a\u670d\u5668\u5c0d\u4e0d\u540c\u8acb\u6c42\u7684\u53cd\u61c9\uff0c\u5f9e\u800c\u63d0\u9ad8\u7db2\u7ad9\u7684\u4e92\u52d5\u6027\u548c\u529f\u80fd\u6027\u3002<\/p>\n<h2 id=\"mod_actions-%e7%9a%84%e5%9f%ba%e6%9c%ac%e5%8a%9f%e8%83%bd-yCWJZvpkNJ\">mod_actions \u7684\u57fa\u672c\u529f\u80fd<\/h2>\n<ul>\n<li><strong>\u52d5\u4f5c\u5b9a\u7fa9\uff1a<\/strong>mod_actions \u5141\u8a31\u7528\u6236\u5b9a\u7fa9\u591a\u7a2e\u52d5\u4f5c\uff0c\u9019\u4e9b\u52d5\u4f5c\u53ef\u4ee5\u6839\u64da\u8acb\u6c42\u7684 MIME \u985e\u578b\u6216\u5176\u4ed6\u689d\u4ef6\u4f86\u89f8\u767c\u3002<\/li>\n<li><strong>CGI \u8173\u672c\u57f7\u884c\uff1a<\/strong>\u7528\u6236\u53ef\u4ee5\u6307\u5b9a\u67d0\u4e9b\u8acb\u6c42\u4f7f\u7528\u7279\u5b9a\u7684 CGI \u8173\u672c\u4f86\u8655\u7406\uff0c\u9019\u5c0d\u65bc\u9700\u8981\u52d5\u614b\u5167\u5bb9\u7684\u7db2\u7ad9\u7279\u5225\u6709\u7528\u3002<\/li>\n<li><strong>\u91cd\u5b9a\u5411\uff1a<\/strong>\u6839\u64da\u8acb\u6c42\u7684\u7279\u5fb5\uff0cmod_actions \u53ef\u4ee5\u5c07\u7528\u6236\u91cd\u5b9a\u5411\u5230\u5176\u4ed6 URL\uff0c\u9019\u5728\u7db2\u7ad9\u7d50\u69cb\u8b8a\u66f4\u6216\u5167\u5bb9\u66f4\u65b0\u6642\u975e\u5e38\u5be6\u7528\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae-mod_actions-yCWJZvpkNJ\">\u5982\u4f55\u914d\u7f6e mod_actions<\/h2>\n<p>\u8981\u4f7f\u7528 mod_actions\uff0c\u9996\u5148\u9700\u8981\u78ba\u4fdd\u8a72\u6a21\u7d44\u5df2\u7d93\u5728 Apache \u4e2d\u555f\u7528\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u6307\u4ee4\u4f86\u6aa2\u67e5\uff1a<\/p>\n<pre><code>apachectl -M | grep actions<\/code><\/pre>\n<p>\u5982\u679c\u6a21\u7d44\u5df2\u555f\u7528\uff0c\u63a5\u4e0b\u4f86\u53ef\u4ee5\u5728 Apache \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u9032\u884c\u8a2d\u7f6e\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u57fa\u672c\u7684\u914d\u7f6e\u7bc4\u4f8b\uff1a<\/p>\n<pre><code>\n# \u5728 httpd.conf \u6216\u76f8\u61c9\u7684\u865b\u64ec\u4e3b\u6a5f\u914d\u7f6e\u4e2d\u6dfb\u52a0\n\n    Action my-action \/cgi-bin\/my-script.cgi\n    AddHandler my-action .myext\n\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u7bc4\u4f8b\u4e2d\uff0c\u7576\u8acb\u6c42\u7684\u6587\u4ef6\u64f4\u5c55\u540d\u70ba .myext \u6642\uff0cApache \u5c07\u6703\u57f7\u884c\u4f4d\u65bc \/cgi-bin\/my-script.cgi \u7684 CGI \u8173\u672c\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8%e7%af%84%e4%be%8b-yCWJZvpkNJ\">\u4f7f\u7528\u7bc4\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u66f4\u5177\u9ad4\u7684\u4f7f\u7528\u7bc4\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u6839\u64da\u8acb\u6c42\u7684 MIME \u985e\u578b\u4f86\u57f7\u884c\u4e0d\u540c\u7684\u52d5\u4f5c\uff1a<\/p>\n<pre><code>\n\n    Action text\/html \/cgi-bin\/html-handler.cgi\n    Action application\/json \/cgi-bin\/json-handler.cgi\n\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u914d\u7f6e\u4e2d\uff0c\u7576\u8acb\u6c42\u7684\u5167\u5bb9\u985e\u578b\u70ba text\/html \u6642\uff0cApache \u5c07\u8abf\u7528 html-handler.cgi\uff1b\u800c\u7576\u8acb\u6c42\u7684\u5167\u5bb9\u985e\u578b\u70ba application\/json \u6642\uff0c\u5247\u8abf\u7528 json-handler.cgi\u3002\u9019\u6a23\u7684\u8a2d\u7f6e\u4f7f\u5f97\u4f3a\u670d\u5668\u80fd\u5920\u6839\u64da\u4e0d\u540c\u7684\u8acb\u6c42\u985e\u578b\u63d0\u4f9b\u76f8\u61c9\u7684\u8655\u7406\u908f\u8f2f\u3002<\/p>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-yCWJZvpkNJ\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u4f7f\u7528 mod_actions \u6642\uff0c\u7ba1\u7406\u54e1\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd CGI \u8173\u672c\u7684\u57f7\u884c\u6b0a\u9650\u6b63\u78ba\u8a2d\u7f6e\uff0c\u4ee5\u907f\u514d\u56e0\u6b0a\u9650\u554f\u984c\u5c0e\u81f4\u7684\u932f\u8aa4\u3002<\/li>\n<li>\u5c0d\u65bc\u91cd\u5b9a\u5411\u64cd\u4f5c\uff0c\u61c9\u8b39\u614e\u8a2d\u7f6e\uff0c\u4ee5\u514d\u9020\u6210\u7121\u9650\u91cd\u5b9a\u5411\u7684\u60c5\u6cc1\u3002<\/li>\n<li>\u5b9a\u671f\u6aa2\u67e5\u548c\u66f4\u65b0 CGI \u8173\u672c\uff0c\u4ee5\u78ba\u4fdd\u5176\u5b89\u5168\u6027\u548c\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-yCWJZvpkNJ\">\u7e3d\u7d50<\/h2>\n<p>mod_actions \u662f Apache \u4e2d\u4e00\u500b\u5f37\u5927\u7684\u64cd\u4f5c\u6a21\u7d44\uff0c\u80fd\u5920\u6839\u64da\u8acb\u6c42\u7684\u7279\u5fb5\u57f7\u884c\u7279\u5b9a\u7684\u52d5\u4f5c\u3002\u901a\u904e\u9748\u6d3b\u7684\u914d\u7f6e\uff0c\u7db2\u7ad9\u7ba1\u7406\u54e1\u53ef\u4ee5\u63d0\u5347\u7db2\u7ad9\u7684\u4e92\u52d5\u6027\u548c\u529f\u80fd\u6027\u3002\u5c0d\u65bc\u9700\u8981\u52d5\u614b\u5167\u5bb9\u8655\u7406\u7684\u7db2\u7ad9\uff0cmod_actions \u63d0\u4f9b\u4e86\u6709\u6548\u7684\u89e3\u6c7a\u65b9\u6848\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u4f3a\u670d\u5668\u914d\u7f6e\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u53ef\u9760\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3Apache\u7684mod_actions\u6a21\u7d44\uff0c\u900f\u904e\u6307\u4ee4\u81ea\u5b9a\u7fa9HTTP\u8acb\u6c42\u7684\u884c\u70ba\uff0c\u63d0\u5347\u7db2\u7ad9\u529f\u80fd\u8207\u9748\u6d3b\u6027\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-33490","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/33490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=33490"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/33490\/revisions"}],"predecessor-version":[{"id":33491,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/33490\/revisions\/33491"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=33490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=33490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=33490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}