{"id":287,"date":"2018-11-16T10:58:39","date_gmt":"2018-11-16T02:58:39","guid":{"rendered":"https:\/\/www.wzh994.cn\/?p=287"},"modified":"2025-09-10T09:42:47","modified_gmt":"2025-09-10T01:42:47","slug":"centos%e9%83%a8%e7%bd%b2flask%e9%a1%b9%e7%9b%ae","status":"publish","type":"post","link":"https:\/\/www.wzh994.cn\/?p=287","title":{"rendered":"Centos\u90e8\u7f72flask\u9879\u76ee"},"content":{"rendered":"<p>\u6700\u8fd1\u8981\u505a\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\uff0c\u67d0\u4e9b\u529f\u80fd\u9700\u8981\u7528\u5230python\u7684\u63d2\u4ef6\uff0c\u6240\u4ee5\u9009\u62e9\u4e86python\u7684flask\u6846\u67b6\u6765\u5199\u540e\u7aef\u7684API\uff0c\u987a\u624b\u51fa\u4e00\u4e2a\u6559\u7a0b\u3002<\/p>\n<p>\u9996\u5148\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u4e86centos\u7cfb\u7edf\u3002<\/p>\n<p>\u4f7f\u7528putty\uff0c\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u767b\u9646\u5230Centos\uff0c\u6253\u5f00\u72b6\u6001\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask1.png\" alt=\"\" \/><\/p>\n<p>\u8f93\u5165\u4e0b\u9762\u6307\u4ee4\u5b89\u88c5\u5b9d\u5854\u670d\u52a1\u5668\u7ba1\u7406\u9762\u677f\u3002\uff08\u8fd9\u4e2a\u9762\u677f\u53ef\u4ee5\u5feb\u6377\u7684\u7ba1\u7406\u670d\u52a1\u5668\u4ee5\u53ca\u5b89\u88c5\u4e00\u4e9b\u5e38\u7528\u8f6f\u4ef6\uff09<\/p>\n<pre><span style=\"color: #666666; font-family: Arial; background-color: #f7f7f7;\">yum install -y wget &amp;&amp; wget -O install.sh <a href=\"http:\/\/download.bt.cn\/install\/install.sh%20&amp;&amp;%20sh%20install.sh\">http:\/\/download.bt.cn\/install\/install.sh &amp;&amp; sh install.sh<\/a>\r\n<\/span><\/pre\r\n\r\n\u4e00\u6bb5\u7b49\u5f85\u540e\uff1a\u5b89\u88c5\u5b8c\u6210 \u7ed9\u51fa\u4e86\u7ba1\u7406\u5730\u5740\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask2.png\" alt=\"\" \/>\r\n\r\n\u6211\u4eec\u6309\u7167\u7ed9\u7684\u5730\u5740\u767b\u9646\u5230\u5b9d\u5854\u9762\u677f\uff0c\u4f1a\u63d0\u793a\u5b89\u88c5\u8f6f\u4ef6\uff0c\u6211\u76ee\u6807\u662f\u4f7f\u7528python\u6765\u505a\u540e\u7aef\uff0c\u6240\u4ee5\u4e0d\u5b89\u88c5php\u8fd9\u91cc\u6211\u53ea\u9009\u62e9\u4e86apache\u548cmysql\uff08\u5982\u679c\u60f3\u5728web\u7aef\u7ba1\u7406\u6570\u636e\u5e93\u53ef\u4ee5\u5b89\u88c5phpmyadmin\uff0c\u6211\u4f7f\u7528navicat\u5c31\u4e0d\u5b89\u88c5\u4e86\uff09\u3002\r\n\r\n\u5b89\u88c5\u4e2d\uff1a\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask3.png\" alt=\"\" \/>\r\n\r\n\u5b89\u88c5\u5b8c\u6210\u540e\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u7ad9\u70b9\u6d4b\u8bd5\u4e00\u4e0b\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask4.png\" alt=\"\" \/>\r\n\r\n\u8bbf\u95ee\u4e00\u4e0b\u7ad9\u70b9\u76ee\u5f55\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask5.png\" alt=\"\" \/>\r\n\r\n\u8fd9\u91cc\u914d\u7f6e\u4e00\u4e0bssl\uff08https\u5b89\u5168\u8bbf\u95ee\uff0c\u975e\u5fc5\u9700\uff09\u70b9\u51fb\u7f51\u7ad9\u8bbe\u7f6e\u2014SSL\uff0c\u5b9d\u5854\u7ed9\u51fa\u4e86\u8be6\u7ec6\u5e2e\u52a9\uff0c\u8fd9\u91cc\u4e0d\u8d58\u8ff0\u3002\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask6.png\" alt=\"\" \/>\r\n\r\n\u518d\u8bbf\u95ee\u4e00\u6b21\u7f51\u7ad9\uff0c\u4ee5\u53ca\u53d8\u6210\u4e86https\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask7.png\" alt=\"\" \/>\r\n\r\n\u63a5\u4e0b\u6765\u5b89\u88c5SVN\uff08\u4ee3\u7801\u4ed3\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u7684\u7ba1\u7406\u4ee3\u7801\uff0c\u5b9d\u5854\u9ed8\u8ba4\u7684ftp\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u4f46\u4e0d\u63a8\u8350\u4f7f\u7528\uff09\r\n\r\n\u5728\u7ec8\u7aef\u8f93\u5165<span style=\"color: #008200; font-family: Consolas; font-size: 9pt; background-color: #f4f4f4;\">yum\u00a0install\u00a0subversion\r\n<\/span>\r\n\r\n\u56de\u8f66\u540e\u81ea\u52a8\u5b89\u88c5\r\n\r\n\u5b89\u88c5\u5b8c\u6210\u540e\u8f93\u5165mkdir {\u8fd9\u91cc\u586b\u4f60\u8981\u653e\u7684\u76ee\u5f55\uff0c\u65e0\u9700\u62ec\u53f7}(\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5b9d\u5854\u7684\u6587\u4ef6\u7ba1\u7406\u6765\u521b\u5efa\uff0c\u540e\u9762\u80fd\u7528\u5b9d\u5854\u8fdb\u884c\u7684\u64cd\u4f5c\u90fd\u7528\u5b9d\u5854\u6765\u505a\u4e86)\r\n\r\n\u6267\u884csvnadmin create \/svn\u521b\u5efa\u4e00\u4e2a\u4ee3\u7801\u4ed3\u5e93\r\n\r\n\u5982\u679c\u62a5\u4e0b\u9762\u7684\u9519\u8bef\r\n\r\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask8.png\" alt=\"\" \/>\r\n\r\n\u5219\u521b\u5efa\u4e0b\u9762\u7684apr\u5171\u4eab\u5e93\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b9d\u5854\u9762\u677f\u7684\u6587\u4ef6\u7ba1\u7406\u521b\u5efa\r\n\r\n\u5728\/etc\/<span style=\"color: blue;\">ld<span style=\"color: black;\">.so.conf.d\/\u76ee\u5f55\u4e0b\u5efa\u7acb\u4e00\u4e2a\u6587\u4ef6httpd-apr.conf\uff0c\u91cc\u9762\u5199\u4e0a\r\n<\/span><\/span>\r\n\r\n<span style=\"color: black; font-family: \u5b8b\u4f53; font-size: 12pt;\">\/www\/server\/apache\/lib\r\n<\/span>\r\n\r\n\u521b\u5efa\u6210\u529f\u540e\uff0c\u6267\u884c\r\n<pre><code><span style=\"color: black;\">ldconfig -v\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\r\n<\/span><\/code><\/pre>\n<p>\u6b64\u65f6svn\u4ed3\u5e93\u53ef\u4ee5\u521b\u5efa\u4e86\uff08\u4e0b\u56fe\u6587\u5b9d\u5854\u6587\u4ef6\u7ba1\u7406\u7684\u663e\u793a\uff09<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask9.png\" alt=\"\" \/><br \/>\n\u76ee\u5f55\u4e0b\u6709\u8fd9\u4e9b\u6587\u4ef6\uff0c\u63a5\u4e0b\u6765\u6211\u914d\u7f6e\u4e00\u4e0b\u3002\uff08\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\u5177\u4f53\u662f\u54ea\u4e2a\u6587\u4ef6\uff09<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask10.png\" alt=\"\" \/><br \/>\n\u53bb\u6389\u56db\u9879\u6ce8\u91ca(\u5220\u9664\u524d\u9762\u7684#\u548c\u7a7a\u683c\u5373\u53ef\uff0c\u56fe\u4e2d\u663e\u793a\u4e3a\u7eff\u8272)<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask11.png\" alt=\"\" \/><br \/>\n\u914d\u7f6e\u7528\u6237\u540d\u548c\u5bc6\u7801 \u8fd9\u91cc\u6211\u968f\u610f\u6dfb\u52a0\u4e86\u51e0\u4e2a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask12.png\" alt=\"\" \/><br \/>\n\u524d\u9762\u662f\u6307\u5b9a\u7528\u6237\u7ec4<br \/>\nrw\u8868\u793a\u8bfb\u5199\u6743\u9650<br \/>\n\u6ce8\u610f\u6700\u540e\u7684* = (\u7a7a)\u610f\u5473\u7740\u9664\u4e86\u7528\u6237\u7ec4\u4ee5\u5916\u6ca1\u6709\u6743\u9650<br \/>\n\u7136\u540e\u6211\u4eec\u53bb\u5b9d\u5854\u7684\u7cfb\u7edf\u5b89\u5168\u91cc\u9762\u653e\u884csvn\u76843690\u7aef\u53e3<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask13.png\" alt=\"\" \/><br \/>\n\u7136\u540e\u6211\u4eec\u542f\u52a8svn <\/p>\n<pre><code><span style=\"color: #008200; font-family: Consolas; font-size: 9pt; background-color: #f4f4f4;\">svnserve\u00a0-d\u00a0-r\u00a0\/svn\/\r\n<\/span><\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u53ef\u4ee5\u8fde\u63a5\u4e86,\u5728\u81ea\u5df1\u7535\u8111\u4e0acheckout    svn:\/\/\u4f60\u7684\u670d\u52a1\u5668ip \u5c1d\u8bd5\u4e00\u4e0b<br \/>\n\u63a5\u4e0b\u6765\u6211\u4eec\u8ba9SVN\u63d0\u4ea4\u7684\u4ee3\u7801\u540c\u6b65\u5230apache\u76ee\u5f55\uff08\u5b9e\u65f6\u66f4\u65b0\uff09<br \/>\n\u9996\u5148\u6211\u4eec\u5728web\u76ee\u5f55\uff08\u5b9d\u5854\u7684\u7ad9\u70b9\u4fe1\u5fc3\u91cc\u9762\u6709\u4f4d\u7f6e\uff09\u4e0bcheckout\u4e00\u6b21  <\/p>\n<pre><code><span style=\"color: black;\">svn co svn:\/\/\u2026\u2026\u6b64\u5904\u7701\u7565\u2026\u2026  \u2026\u2026\u8fd9\u91cc\u662fweb\u76ee\u5f55\u2026\u2026\r\n<\/span><\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask14.png\" alt=\"\" \/><br \/>\n\u56de\u5230svn\u7684hooks\u76ee\u5f55\u4e0b\uff0c\u521b\u5efa\u6587\u4ef6<\/p>\n<pre><code><span style=\"color: green; font-family: Verdana; font-size: 10pt; background-color: white;\">post-commit\r\n<\/span><\/code><\/pre>\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<pre><code><span style=\"color: black;\">#!\/bin\/sh\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">REPOS=\"$1\"\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">REV=\"$2\"\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">export LANG=en_US.utf8\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">SVN_PATH=\/usr\/bin\/svn\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">WEB_PATH=\u2026\u2026\u8fd9\u91cc\u662fweb\u76ee\u5f55\u2026\u2026\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">$SVN_PATH update $WEB_PATH --username '\u7528\u6237\u540d' --password '\u5bc6\u7801' --no-auth-cache\r\n<\/span><\/code><\/pre>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e0b\u770b\u80fd\u4e0d\u80fd\u6210\u529f\u540c\u6b65\u3002<br \/>\n\u63a5\u4e0b\u6765\u6709\u4e2a\u6bd4\u8f83\u5751\u7684\u95ee\u9898 \u5b89\u88c5python3\uff0c\u5982\u679c\u4f7f\u7528python2\u5c31\u4e0d\u9700\u8981\u5b89\u88c5\u4e86\uff0c\u539f\u6709\u7684python2\u4e0d\u80fd\u53d8\u52a8\uff0c\u5347\u7248\u672c\u90fd\u4e0d\u884c\u3002\u5426\u5219\u5b9d\u5854\u9762\u677f\u65e0\u6cd5\u4f7f\u7528\u3002<br \/>\n\u8fd9\u91cc\u8981\u6ce8\u610f\u4e00\u70b9\u5b89\u88c5\u5fc5\u8981\u5de5\u5177 yum-utils \uff0c\u5b83\u7684\u529f\u80fd\u662f\u7ba1\u7406repository\u53ca\u6269\u5c55\u5305\u7684\u5de5\u5177 (\u4e3b\u8981\u662f\u9488\u5bf9repository)<\/p>\n<pre><code><span style=\"color: black;\">yum install libffi-devel -y\uff08\u8fd9\u4e2a\u4e00\u822c\u88ab\u4eba\u5ffd\u7565\uff09\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">sudo yum install yum-utils\r\n<\/span><\/code><\/pre>\n<p>\u4f7f\u7528yum-builddep\u4e3aPython3\u6784\u5efa\u73af\u5883,\u5b89\u88c5\u7f3a\u5931\u7684\u8f6f\u4ef6\u4f9d\u8d56,\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u4f1a\u81ea\u52a8\u5904\u7406.<\/p>\n<pre><code><span style=\"color: black;\">sudo yum-builddep python\r\n<\/span><\/code><\/pre>\n<p>\u5b8c\u6210\u540e\u4e0b\u8f7dPython3\u7684\u6e90\u7801\u5305\uff08\u7b14\u8005\u4ee5Python3.7.1\u4e3a\u4f8b\uff09\uff0cPython\u6e90\u7801\u5305\u76ee\u5f55\uff1a <a href=\"https:\/\/www.python.org\/ftp\/python\/\"><span style=\"color: #0563c1; text-decoration: underline;\">https:\/\/www.python.org\/ftp\/python\/<\/span><\/a>\uff0c\u6267\u884c<\/p>\n<pre><code><span style=\"color: black;\">curl -O https:\/\/www.python.org\/ftp\/python\/3.7.1\/Python-3.7.1.tgz\r\n<\/span><\/code><\/pre>\n<p>\u6700\u540e\u4e00\u6b65\uff0c\u7f16\u8bd1\u5b89\u88c5Python3\uff0c\u9ed8\u8ba4\u7684\u5b89\u88c5\u76ee\u5f55\u662f \/usr\/local \u5982\u679c\u4f60\u8981\u6539\u6210\u5176\u4ed6\u76ee\u5f55\u53ef\u4ee5\u5728\u7f16\u8bd1(make)\u524d\u4f7f\u7528 configure \u547d\u4ee4\u540e\u9762\u8ffd\u52a0\u53c2\u6570 \"\u2013prefix=\/alternative\/path\" \u6765\u5b8c\u6210\u4fee\u6539\u3002<\/p>\n<pre><code><span style=\"color: black;\">$ tar xf Python-3.7.1.tgz\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">$ cd Python-3.7.1\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">$.\/configure --enable-shared  \uff08--enable-shared\u5f88\u91cd\u8981\uff0c\u8fd9\u4e2a\u5751\u4e5f\u5f88\u5927\uff0c\u4e0d\u6dfb\u52a0\u53ef\u4ee5\u6b63\u5e38\u5b89\u88c5\uff0c\u4f46\u662f\u4f1a\u5f71\u54cdmod\uff09\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">$ make\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">$ sudo make install\r\n<\/span><\/code><\/pre>\n<p>\u5b89\u88c5\u6210\u529f<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask15.png\" alt=\"\" \/><br \/>\n<span style=\"color: #444444; font-size: 11pt;\"><span style=\"font-family: Helvetica; background-color: white;\">\/etc\/profile.d\/<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u76ee\u5f55\u4e0b\u5efa<\/span><span style=\"font-family: Helvetica; background-color: white;\">python3.sh<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u548c<\/span><span style=\"font-family: Helvetica; background-color: white;\">pip3.sh<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\uff08<\/span><span style=\"font-family: Helvetica; background-color: white;\">pip<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u662f<\/span><span style=\"font-family: Helvetica; background-color: white;\">python<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u5b89\u88c5\u6269\u5c55\u7684\u5de5\u5177\uff09<\/span><br \/>\n\t\t\t\t\t<\/span><br \/>\n<span style=\"color: #444444; font-size: 11pt;\"><span style=\"font-family: Helvetica; background-color: white;\">alias python='\/usr\/local\/bin\/python3.7  <\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u6307\u5411\u5bf9\u5e94\u7684\u6587\u4ef6\uff0c<\/span><span style=\"font-family: Helvetica; background-color: white;\"> pip<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u540c<\/span><br \/>\n\t\t\t\t\t<\/span><br \/>\n<span style=\"color: #444444;\"><span style=\"font-family: \u5b8b\u4f53; font-size: 11pt; background-color: white;\">\u7136\u540e<\/span><span style=\"color: #4f4f4f;\"><span style=\"font-family: Arial; background-color: white;\">ldconfig<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\uff08\u91cd\u8f7d\u914d\u7f6e\uff09\u4e00\u4e0b<\/span><span style=\"font-family: Arial; background-color: white;\">  python3<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u548c<\/span><span style=\"font-family: Arial; background-color: white;\">pip3<\/span><span style=\"font-family: \u5b8b\u4f53; background-color: white;\">\u5c31\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u4e86<\/span><br \/>\n\t\t\t\t\t\t<\/span><\/span><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask16.png\" alt=\"\" \/><br \/>\n\u6211\u4eec\u5b89\u88c5\u4e00\u4e0bflask\u6846\u67b6<\/p>\n<pre><code><span style=\"color: black;\">\u6267\u884cpip3 install flask\r\n<\/span><\/code><\/pre>\n<p>\u7136\u540e\u5230\u4e86mod_wsgi\u4e86\uff0c\u5f88\u591a\u4eba\u5728\u8fd9\u91cc\u4f1a\u9047\u5230\u627e\u4e0d\u5230\u5bf9\u5e94\u7248\u672c\u7684mod_wsgi.so\uff08windows\u4e0b\u662fwhl\u6587\u4ef6\uff09\u7684\u95ee\u9898\uff0c\u6216\u8005\u7248\u672c\u4e0d\u5339\u914d\uff0c\u7f51\u4e0a\u7684\u6559\u7a0b\u5927\u90e8\u5206\u90fd\u662f\u5efa\u8bae\u53bb\u627e\u8fd9\u4e2a\u5bf9\u5e94\u7248\u672c\u7684\u4e0b\u8f7d\u3002<br \/>\n\u5176\u5b9e\u8fd9\u4e2a\u6587\u4ef6\u662f\u53ef\u4ee5\u81ea\u5df1\u7f16\u8bd1\u7684\u4e0b\u8f7dmod_wsgi\u7684\u6e90\u4ee3\u7801\u5305\uff0c\u89e3\u538b\u7f29\u540e\u7f16\u8bd1\uff1a<\/p>\n<pre><code><span style=\"color: black;\">wget https:\/\/files.pythonhosted.org\/packages\/47\/69\/5139588686eb40053f8355eba1fe18a8bee94dc3efc4e36720c73e07471a\/mod_wsgi-4.6.5.tar.gz\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">tar zxvf .\/ mod_wsgi-4.6.5.tar.gz\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">cd mod_wsgi-4.6.5\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">.\/configure --with-apxs=\/www\/server\/apache\/bin\/apxs --with-python=\/usr\/local\/bin\/python3\r\n<\/span><\/code><\/pre>\n<p><span style=\"color: black;\">apxs\u662fapache\u7684\u4e1c\u897f\uff0c\u9700\u8981\u6307\u5b9a\u5bf9\u5e94\u76ee\u5f55\u81ea\u5df1\u6539<\/p>\n<pre><code><span style=\"color: black;\">make\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">make install\r\n<\/span><\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask17.png\" alt=\"\" \/><br \/>\n\u5b89\u88c5\u5b8c\u6210\uff0c\u770b\u5230\u6ca1\u6709\uff0cmod_wsgi.so\u81ea\u5df1\u751f\u6210\u5230apache\u7684\u6a21\u5757\u76ee\u5f55\u4e0b\u4e86\u3002<br \/>\n\u8fd8\u9700\u8981\u628amod_wsgi\u52a0\u8f7d\u5230apache\u76ee\u5f55\u7684<span style=\"font-size: 10pt;\"><span style=\"font-family: Consolas;\"><span style=\"background-color: #f6f8fa;\">conf\/httpd<\/span><span style=\"color: #009900;\">.conf<\/span><\/span><span style=\"font-family: \u5b8b\u4f53;\">\u91cc\u9762<\/span><br \/>\n\t\t\t\t\t\t<\/span><\/p>\n<pre><code><span style=\"color: black;\">\u6dfb\u52a0\u4e00\u884c <span style=\"font-family: Consolas; font-size: 10pt;\"><span style=\"background-color: #f6f8fa;\">LoadModule wsgi_module modules\/mod_wsgi<\/span><span style=\"color: #009900;\">.so<\/span><\/span>\r\n\t\t\t\t\t<\/span><\/code><\/pre>\n<p>\u81f3\u6b64\u6240\u6709\u8f6f\u4ef6\u90fd\u88c5\u5b8c\u4e86 \u6211\u4eec\u5c1d\u8bd5\u90e8\u7f72\u4e00\u4e2a\u7b80\u6613flask\u9879\u76ee\uff0c\u6ce8\u610f\uff0c\u8fd9\u4e9b\u6587\u4ef6\u5fc5\u987b\u4f7f\u7528Linux\u7f16\u7801\uff0cwindow\u4e0b\u521b\u5efa\u7684\u6587\u4ef6\u76f4\u63a5\u4e0a\u4f20\u4f1a\u62a5500\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask18.png\" alt=\"\" \/><\/p>\n<pre><code>\r\n\t\t\t\t<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask19.png\" alt=\"\" \/><\/p>\n<pre><code>\r\n\t\t\t\t<\/code><\/pre>\n<p>\u914d\u7f6e\u4e00\u4e0bapache\u7684httpd.conf\uff08\u7531\u4e8e\u6211\u4eec\u4f7f\u7528\u7684\u5b9d\u5854\uff09<br \/>\n\u5b9e\u9645\u7f51\u7ad9\u7684\u914d\u7f6e\u76ee\u5f55\u4e3a\/www\/server\/panel\/vhost\/apache\/*.conf\uff08\u5728httpd.conf\u4e2dinclude\u4e86\u8fd9\u4e2a\u6587\u4ef6\uff09<br \/>\n\u5728443\uff08\u56e0\u4e3a\u524d\u9762\u914d\u7f6e\u4e86https\uff0c\u6ca1\u914d\u7f6ehttps\u9ed8\u8ba4\u662f\u572880\u7aef\u53e3\u4e0b\uff09\u7aef\u53e3\u7684&lt;VirtualHost&gt;\u91cc\u9762\u52a0\u4e0a\uff0c\u76ee\u5f55\u81ea\u884c\u5bf9\u5e94\u4fee\u6539<\/p>\n<pre><code><span style=\"color: black;\">   &lt;Directory \"\/www\/wwwroot\/\u2026\u2026\u8fd9\u91cc\u662fapache\u7ad9\u70b9\u76ee\u5f55\u2026\u2026\/webapi\/\"&gt;\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">\u00a0\u00a0\u00a0\u00a0AllowOverride All\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">\u00a0\u00a0\u00a0\u00a0Require all granted\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">    &lt;\/Directory&gt;\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">    WSGIDaemonProcess webapi python-path=\/usr\/local\/lib\/python3.7\/site-packages\uff08\u8fd9\u4e00\u884c\u5f88\u91cd\u8981\uff0c\u5bb9\u6613\u88ab\u5ffd\u89c6\uff0c\u6ca1\u6709\u7684\u8bdd\u5373\u4f7fimport\u4e86flask\uff0c\u4e5f\u4e0d\u80fd\u4f7f\u7528\uff0c\u62a5\u9519500\uff09\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">    WSGIProcessGroup webapi\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">WSGIScriptAlias \/webapi \/www\/wwwroot\/\u2026\u2026\u8fd9\u91cc\u662fapache\u7ad9\u70b9\u76ee\u5f55\u2026\u2026 \/webapi\/webapi.wsgi\r\n<\/span><\/code><\/pre>\n<p>\u597d\u5566\u5168\u90fd\u641e\u5b9a\u5566\uff0c\u8bbf\u95ee\u8bd5\u4e00\u4e0b\uff1a<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wzh994.cn\/wp-content\/uploads\/2018\/11\/111618_0258_Centosflask20.png\" alt=\"\" \/><br \/>\n\u914d\u7f6e\u6210\u529f\uff01<br \/>\n\u987a\u4fbf\u63d0\u4e00\u4e0b\u901a\u8fc7CGI\u76f4\u63a5\u6267\u884c*.py\u7a0b\u5e8f\u7684\u914d\u7f6e\u65b9\u5f0f<br \/>\n\u901a\u8fc7cgi\u8bbf\u95eepython \uff0c\u8fd8\u662f\u4fee\u6539\u4e0a\u9762\u90a3\u4e2aconf\u6587\u4ef6<\/p>\n<pre><code><span style=\"color: black;\">   &lt;Directory \"\/www\/wwwroot\/\u2026\u2026\u8fd9\u91cc\u662fapache\u7ad9\u70b9\u76ee\u5f55\u2026\u2026\/webapi\/\"&gt;\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">   AllowOverride None\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">   Options +ExecCGI\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">   Order allow,deny\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">   Allow from all\r\n<\/span><\/code><\/pre>\n<pre><code><span style=\"color: black;\">&lt;\/Directory&gt;\r\n<\/span><\/code><\/pre>\n<p>\u4e0d\u9700\u8981\u914d\u7f6e\u8def\u7531\uff0c\u76f4\u63a5\u8bbf\u95ee*.py\u5c31\u53ef\u4ee5\u4e86\uff08\u4f46\u662f\u8fd9\u6837\u662f\u4e0d\u80fd\u4f7f\u7528web\u6846\u67b6\u7684\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u8981\u505a\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\uff0c\u67d0\u4e9b\u529f\u80fd\u9700\u8981\u7528\u5230python\u7684\u63d2\u4ef6\uff0c\u6240\u4ee5\u9009\u62e9\u4e86python\u7684flask\u6846\u67b6\u6765\u5199\u540e\u7aef\u7684API [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":289,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[95],"tags":[14,41,42,43,16],"class_list":["post-287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-95","tag-apache","tag-centos","tag-flask","tag-mod_wsgi","tag-python"],"_links":{"self":[{"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=287"}],"version-history":[{"count":6,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":442,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/posts\/287\/revisions\/442"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=\/wp\/v2\/media\/289"}],"wp:attachment":[{"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wzh994.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}