2016-07-04 183 views
0

引言

我有一个在python 3中编写的Web API,它使用了flask。当我从终端运行Web API时,代码运行良好,并且它从代码中的以下行托管。如何在虚拟环境中安装mod_wsgi

if __name__ == '__main__': 
    app.run(host='', port=8010, debug='true') 

现状

的代码完全运行,我想将它设置Apache服务器上。然而Apache服务器已经有使用python 2构建的网站,并且需要python 2的mod_wsgi。

我抬头看看是否有办法在apache服务器上设置mod-wsgi,但根据以下来源不能 mod_wsgi for Python 2 as well as Python 3 on one Apache server

尝试一个解决方案,

我试图到MOD-WSGI安装到虚拟环境。我从这里下载了软件包,并尝试在激活它之后将其安装到环境中。

我跑从终端sudo python setup.py install但我得到了下面

File "setup.py", line 139, in 'missing Apache httpd server packages.' % APXS) RuntimeError: The 'apxs' command appears not to be installed or is not executable. Please check the list of prerequisites in the documentation for this package and install any missing Apache httpd server packages.

所以,我打开自述文件,该文件是压缩包的一部分错误,发现如下

If you wish to use a version of Apache which is installed into a non standard location, you can set and export the APXS environment variable to the location of the Apache apxs script for your Apache installation before performing the installation.

Note that nothing will be copied into your Apache installation at this point. As a result, you do not need to run this as the root user unless installing it into a site wide Python installation rather than a Python virtual environment.

To verify that the installation was successful, run the mod_wsgi-express script with the start-server command::

mod_wsgi-express start-server 

这似乎解决我的情况,因为Apache没有安装在我运行命令的虚拟环境中,但我不知道该怎么办。

I presu我说的是他们正在讨论的setup.py文件,我应该改变路径,但我不知道如何做到这一点语法明智或我的APXS脚本位于。

这里是我觉得需要的代码片段修改

APXS = os.environ.get('APXS') 

WITH_HTTPD_PACKAGE = False 

if APXS is None: 
    APXS = find_program(['mod_wsgi-apxs'], 
      paths=[os.path.dirname(sys.executable)]) 
    if APXS is not None: 
     WITH_HTTPD_PACKAGE = True 

if APXS is None: 
    APXS = find_program(['mod_wsgi-apxs', 'apxs2', 'apxs'], 
      'apxs', ['/usr/sbin', os.getcwd()]) 
elif not os.path.isabs(APXS): 
    APXS = find_program([APXS], APXS, ['/usr/sbin', os.getcwd()]) 

if not WITH_TARBALL_PACKAGE: 
    if not os.path.isabs(APXS) or not os.access(APXS, os.X_OK): 
     raise RuntimeError('The %r command appears not to be installed or ' 
       'is not executable. Please check the list of prerequisites ' 
       'in the documentation for this package and install any ' 
       'missing Apache httpd server packages.' % APXS) 

问题

我做的这一切运行Ubuntu 12.04LTS如果它帮助的服务器上。我在最后的问题有以下几种

  1. 哪里APXS位于通常在Ubuntu
  2. 如何更改代码段尽量使用APXS脚本有

谢谢你这么多你的时间

+0

对不起,误解 原来APXS没有安装在我的APACHE –

回答

1

很抱歉给您带来不便

原来我忘了我的Apache服务器上安装APXS。我只是运行从终端代码,它的工作 sudo apt-get apache2-threaded-dev

相关问题