在Windows 7上的Apache上部署Python Flask API

时间:2017-06-02 13:06:45

标签: python apache flask mod-wsgi wsgi

我正在尝试在Windows 7上使用Python Flask API部署Apache。我发现由于Python不是本机开发语言,因此需要WSGI (Web Service Gateway Interface)才能连接到Apache。我也找到了一些教程,但没有一个对我有用:

1- Running a Flask application under the Apache WSGI module

对于本教程,当我运行sudo a2ensite my.webtool时,我收到一条错误消息,指出a2ensite不是内部或外部命令。

2- mod_wsgi (Apache)

对于这个,我遵循了所有步骤。我只更改了ServerName

<VirtualHost *:80>
    ServerName example.com
    WSGIScriptAlias / C:\yourdir\yourapp.wsgi
    <Directory C:\yourdir>
            Require all granted
    </Directory>
</VirtualHost>

因此,example.com而不是my-flask我放了httpd-vhosts.conf,当然我改变了应用程序的路径并将其保存在/etc/hosts文件中。然后我在127.0.0.1 my-flask

中添加了这一行
httpd.conf

最后在#文件中,我从此行中删除了Include conf/extra/httpd-vhosts.conf

The requested operation has failed!

问题是当我重新启动Apache Server时,它没有启动,我收到一条错误消息:my-flask.wsgi

[UPDATE]

import sys sys.path.insert(0, 'C:/Users/Cybula-EDF/Documents/Flask/prod') from my-flask import app as application 文件如下所示:

LoadModule

这是> mod_wsgi-express module-config LoadModule wsgi_module "c:/python27/lib/site-packages/mod_wsgi-4.5.14-py2.7-win-amd64.egg/mod_wsgi/server/mod_wsgiNone" WSGIPythonHome "C:/Python27" 所说的:

c:/python27/lib/site-packages/mod_wsgi-4.5.14-py2.7-win-amd64.egg/mod_wsgi/server/

这是 Name | Type ---------------------------------------------- management | (File folder) __init__ | (Python File) __init__ | (Compiled Python File) apxs_config | (Python File) apxs_config | (Compiled Python File) environ | (Python File) environ | (Compiled Python File) mod_wsgi | (Python File) mod_wsgi | (Compiled Python File) mod_wsgi | (Python Extension Module) ----------------------------------------------- 下的内容:

mod_wsgi

Python扩展模块.pyd的扩展名为localhost/hello_world.wsgi

3- Using Apache and Python WSGI on Windows

当我遵循这个时,Apache Server工作正常,但是当我键入:

Hello World!

它没有显示library(ggplot2) d_date <- Sys.Date() d_value_1 <- c(1,3,4,0,0) d_value_2 <- c(-1,-2,-8,5,0) d_value_3 <- c(5,5,4,2,0) df_plot_1 <- data.frame("date" = seq(d_date, d_date + 4, 1), "value" = cumsum(d_value_1), "name" = "Name1") df_plot_2 <- data.frame("date" = seq(d_date, d_date + 4, 1), "value" = cumsum(d_value_2), "name" = "Name2") df_plot_3 <- data.frame("date" = seq(d_date, d_date + 4, 1), "value" = cumsum(d_value_3), "name" = "Name3") df_plot <- rbind(df_plot_1, df_plot_2, df_plot_3) ggplot(df_plot, aes(x=date, y=value, fill=name)) + geom_area() ,而是显示了一个页面,其中包含错误消息,指出无法找到该页面。

任何人都可以告诉我,我做错了什么?也许我错过了一些细节或其他东西。谢谢!

0 个答案:

没有答案