{"id":198,"date":"2012-11-26T10:43:00","date_gmt":"2012-11-26T07:43:00","guid":{"rendered":"http:\/\/blog.successionua.com\/?p=198"},"modified":"2021-09-24T00:00:50","modified_gmt":"2021-09-23T21:00:50","slug":"hello-world-%d1%81-%d0%bf%d0%be%d0%bc%d0%be%d1%89%d1%8c%d1%8e-mod_python","status":"publish","type":"post","link":"https:\/\/geckich.space\/?p=198","title":{"rendered":"Hello world! \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e mod_python"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0430\u0439\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c mod_python \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u0442\u0430\u043f\u043e\u0432: \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (apache) \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<div><\/div>\n<div>1. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/div>\n<div>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044c, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0435\u0442:<\/div>\n<\/div>\n<div><\/div>\n<div dir=\"ltr\" style=\"text-align: left;\">\n<div>\n<p><b><span style=\"color: #e69138;\">aptitude install libapache2-mod-python<\/span><\/b><br \/>\n<b><span style=\"color: #e69138;\">a2enmod python<\/span><\/b><\/p>\n<p>\u041f\u043e\u0434\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 Debian \u0444\u0430\u0439\u043b<b><span style=\"color: #e69138;\"> \/etc\/apache2\/sites-available\/default<\/span><\/b> :<\/p>\n<div style=\"background: #202020; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #6ab825; font-weight: bold;\">&lt;VirtualHost<\/span> <span style=\"color: #ed9d13;\">*:80<\/span><span style=\"color: #6ab825; font-weight: bold;\">&gt;<\/span>\n        <span style=\"color: #24909d;\">ServerAdmin<\/span> webmaster@localhost\n        <span style=\"color: #24909d;\">DocumentRoot<\/span> <span style=\"color: orange;\">\/var\/www<\/span>\n        <span style=\"color: #6ab825; font-weight: bold;\">&lt;Directory<\/span> <span style=\"color: #ed9d13;\">\/var\/www\/<\/span><span style=\"color: #6ab825; font-weight: bold;\">&gt;<\/span>\n                <span style=\"color: #24909d;\">Options<\/span> Indexes MultiViews\n                <span style=\"color: #24909d;\">AllowOverride<\/span> <span style=\"color: #6ab825; font-weight: bold;\">None<\/span>\n                <span style=\"color: #24909d;\">Order<\/span> allow,deny\n                <span style=\"color: #24909d;\">allow<\/span> from <span style=\"color: #6ab825; font-weight: bold;\">all<\/span>\n                <span style=\"color: #24909d;\">AddHandler<\/span> mod_python .py        #\u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0430\u043f\u0430\u0447\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 *.py \u0432 mod_python\n                <span style=\"color: #24909d;\">PythonHandler<\/span> index                     #\u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u043e\u0432.\n                <span style=\"color: #24909d;\">DirectoryIndex<\/span> index.py                #\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\n        <span style=\"color: #6ab825; font-weight: bold;\">&lt;\/Directory&gt;<\/span>\n        <span style=\"color: #24909d;\">ErrorLog<\/span> ${APACHE_LOG_DIR}\/error.log\n        <span style=\"color: #24909d;\">LogLevel<\/span> <span style=\"color: #6ab825; font-weight: bold;\">warn<\/span>\n        <span style=\"color: #24909d;\">AddHandler<\/span> mod_python .py\n        <span style=\"color: #24909d;\">PythonHandler<\/span> mod_python.publisher\n        <span style=\"color: #24909d;\">PythonDebug<\/span> <span style=\"color: #6ab825; font-weight: bold;\">On<\/span>                                  #\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 - \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440 \u0438\u043e\u0442\u043b\u0430\u0434\u043a\u0435\n        <span style=\"color: #24909d;\">DirectoryIndex<\/span> index.py\n        <span style=\"color: #24909d;\">CustomLog<\/span> ${APACHE_LOG_DIR}\/access.log combined\n<span style=\"color: #6ab825; font-weight: bold;\">&lt;\/VirtualHost&gt;<\/span><\/pre>\n<\/div>\n<\/div>\n<div>\u0410\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0445\u043e\u0441\u0442 (\u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d) \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0432 \u0441\u0438\u043b\u0443:<\/div>\n<div><\/div>\n<div>\n<p><b><span style=\"color: #e69138;\">a2ensite default<\/span><\/b><br \/>\n<b><span style=\"color: #e69138;\">service apache2 restart<\/span><\/b><\/p>\n<\/div>\n<div>2. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430:<\/div>\n<div><\/div>\n<div>\n<div style=\"background: #202020; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #6ab825; font-weight: bold;\">from<\/span> <span style=\"color: #447fcf; text-decoration: underline;\">mod_python<\/span> <span style=\"color: #6ab825; font-weight: bold;\">import<\/span> <span style=\"color: #d0d0d0;\">apache<\/span>          <span style=\"color: #999999; font-style: italic;\">#\u0438\u043c\u043f\u043e\u0440\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 apache<\/span>\n<span style=\"color: #6ab825; font-weight: bold;\">def<\/span> <span style=\"color: #447fcf;\">handler<\/span><span style=\"color: #d0d0d0;\">(req):<\/span>                      <span style=\"color: #999999; font-style: italic;\">#\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0430<\/span>\n    <span style=\"color: #d0d0d0;\">req.content_type<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #ed9d13;\">\"text\/html\"<\/span>     <span style=\"color: #999999; font-style: italic;\">#\u0437\u0430\u0434\u0430\u0435\u043c \u0442\u0438\u043f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b<\/span>\n    <span style=\"color: #d0d0d0;\">req.send_http_header()<\/span>             <span style=\"color: #999999; font-style: italic;\">#\u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0434\u0435\u0444\u043e\u043b\u0442\u043e\u0432\u043e\u0433\u043e \u0445\u044d\u0434\u0435\u0440\u0430 html-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b<\/span>\n    <span style=\"color: #d0d0d0;\">req.write(<\/span><span style=\"color: #ed9d13;\">\"Hello World!\"<\/span><span style=\"color: #d0d0d0;\">)<\/span>          <span style=\"color: #999999; font-style: italic;\">#\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c Hello World! \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443<\/span>\n    <span style=\"color: #6ab825; font-weight: bold;\">return<\/span> <span style=\"color: #d0d0d0;\">apache.OK<\/span>                   <span style=\"color: #999999; font-style: italic;\">#\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u041e\u041a\n<\/span><\/pre>\n<\/div>\n<p>\u041d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <span style=\"color: #e69138;\"><b>index.py<\/b><\/span> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b-\u0445\u043e\u0441\u0442\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \/var\/www), \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u044f \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0445\u043e\u0437\u044f\u0438\u043d\u0430 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 www-data. \u041f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b index.html \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0445\u043e\u0441\u0442\u0430 \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0431\u0443\u043a\u0432\u044b \u0438\u0437 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 &#8211; \u0438\u043d\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0443\u0433\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/div>\n<div>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 Hello World \u043d\u0430 mod_python:<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"http:\/\/4.bp.blogspot.com\/-_0m4U_q7mew\/ULNGtcKO8UI\/AAAAAAAABJg\/QWeAv78CpgY\/s1600\/Screenshot+from+2012-11-26+12:38:00.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/4.bp.blogspot.com\/-_0m4U_q7mew\/ULNGtcKO8UI\/AAAAAAAABJg\/QWeAv78CpgY\/s640\/Screenshot+from+2012-11-26+12:38:00.png\" width=\"640\" height=\"168\" border=\"0\" \/><\/a><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0430\u0439\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c mod_python \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u0442\u0430\u043f\u043e\u0432: \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (apache) \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. 1. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430: \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044c, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0435\u0442: aptitude install libapache2-mod-python a2enmod python \u041f\u043e\u0434\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 Debian \u0444\u0430\u0439\u043b \/etc\/apache2\/sites-available\/default : &lt;VirtualHost *:80&gt; ServerAdmin webmaster@localhost DocumentRoot \/var\/www &lt;Directory \/var\/www\/&gt; Options Indexes MultiViews AllowOverride None Order allow,deny allow from &hellip; <a href=\"https:\/\/geckich.space\/?p=198\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Hello world! \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e mod_python<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-198","post","type-post","status-publish","format-standard","hentry","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198"}],"version-history":[{"count":2,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":1238,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions\/1238"}],"wp:attachment":[{"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}