xampp apache_在Windows上使用Xampp Apache服务Flask应用程序

xampp apache

As we all know Flask, Flask is a web microframework written in python. Flask has a lot of advantages including (for myself) is an easy and agile way of developing web services. Unfortunately, not really agile in a way of deploying into production. That’s why I decided to make this article to tell people how difficult and hideous it is to deploy a Flask app to XAMPP Apache web service and another reason is to make sure I won’t get trouble if I had to deploy Flask again.

众所周知,Flask是用python编写的Web微框架。 Flask有很多优点,包括(对我自己而言)是一种开发Web服务的简单而敏捷的方法。 不幸的是,在部署到生产环境中并没有真正敏捷。 这就是为什么我决定写这篇文章来告诉人们将Flask应用程序部署到XAMPP Apache Web服务有多么困难和可怕,另一个原因是要确保如果我不得不再次部署Flask不会遇到麻烦。

So, to deploy our Flask app, our main module to use is called mod-wsgi. This library is maintained by someone called Graham Dumpleton (even though I wrote this article without asking his approval), and I’d like to say thank you so much for maintaining this wonderful tools for us.

因此,要部署我们的Flask应用,我们要使用的主要模块称为mod-wsgi。 这个库是由一个叫Graham Dumpleton的人维护的(即使我写这篇文章时并没有征得他的同意),我要非常感谢您为我们维护了这个很棒的工具。

Now let’s jump into technical things. Before I know anything about mod-wsgi, I found a tutorial by Thilina Madumal on how exactly to serve a Flask app on Apache. And before you read this article any further, I suggest you read that article first in here.

现在让我们跳入技术性话题。 在不了解mod-wsgi之前 ,我找到了Thilina Madumal的教程,内容涉及如何在Apache上准确地提供Flask应用程序。 而且,在您进一步阅读本文之前,建议您首先在此处阅读该文章。

先决条件 (Prerequisites)

As mentions by Madumal in his article above, you’re going to need to prepare some installations.

正如Madumal在他的上一篇文章中提到的那样,您将需要准备一些安装。

  1. Visual C++ Redistributable for Visual Studio

    Visual Studio的Visual C ++可再发行组件
  2. Visual C++ Build Tools (https://visualstudio.microsoft.com/visual-cpp-build-tools/)

    Visual C ++生成工具(https://visualstudio.microsoft.com/visual-cpp-build-tools/)
  3. python3 (Installed for all user, so make sure installation directory doesn’t go to “C:/Users”)

    python3(已为所有用户安装,因此请确保安装目录未转到“ C:/ Users”)
  4. python3-pip

    python3-pip
  5. XAMPP Apache

    XAMPP Apache

And this is going to be very important in windows machine

这在Windows机器中将非常重要

MAKE SURE YOU INSTALLED PYTHON, APACHE, AND VISUAL STUDIO AS THE SAME BINARY. For example, all of them are 32-bit version OR all of them are 64-bit version.

确保您将PYTHON,APACHE和VISUAL STUDIO安装为相同的二进制文件。 例如,它们都是32位版本,或者它们都是64位版本。

Because if you didn’t make all of that with the same binary, you’re going to face a lot of errors. This statement also mentioned by Graham in this link. As for me myself, I used the 64-bit version of Python 3.8, and 64-bit version of XAMPP Apache (yes, there is a 64-bit version of it).

因为如果不使用相同的二进制文件来实现所有功能,那么您将面临很多错误。 Graham在此链接中也提到了此声明。 至于我自己,我使用的是Python 3.8的64位版本和XAMPP Apache的64位版本(是的,它有64位版本)。

After you installed all of that to your machine, I’m going to assume you have installed python and apache in an easy directory.

在将所有这些安装到计算机上之后,我将假定您已在简单目录中安装了python和apache。

For Python directory, I’m assuming it will be residing in the program files directory, so it’s going to be something like “C:/Program Files/Python”. Because that’s the default path for all user installation. We are going to call that <Python Home> directory for this article.

对于Python目录,我假设它将位于程序文件目录中,因此它将类似于“ C:/ Program Files / Python”。 因为这是所有用户安装的默认路径。 我们将在本文中将该目录称为<Python Home>目录。

And for XAMPP Apache, it would be something like “C:/XAMPP/Apache” and we’ll call that <Apache Home> directory.

对于XAMPP Apache,它将类似于“ C:/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值