Category Archives: apxs2

How to Install mod_wsgi in a virtual Environement

Introduction

I have a Web API writtten in python 3 and it uses flask. The code runs fine when I run the web API from the terminal and it is hosted from the following line in the code.

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

Current Situation

The code runs perfectly and I want to set it up on an Apache Server. However the Apache server already has websites that were built using python 2 and need mod_wsgi for python 2.

I looked up if there was a way to set up both mod-wsgi on the apache server but according to the following source you can't mod_wsgi for Python 2 as well as Python 3 on one Apache server

Attempt at a solution

I 'm trying to install mod-wsgi into a virtual environment. I downloaded the package from here and tried to install it into the environment after activating it.

I ran sudo python setup.py install from the terminal but I got the error below

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.

So I opened the Read Me file that was part of zipped package and found the following

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

It seems to tackle my situation since Apache is not installed in the virtual environment that I'm running the command from but I have no idea how to do it

I presume they are talking about the setup.py file and that I should change the path but I do not know how to do it syntax wise or where my APXS script is located.

Here is snippet of the code that I think needs to be modified

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)

The Question

I'm doing all of this on a server running UBuntu 12.04LTS if it helps. My question at the end are the following

  1. Where is the APXS located usually in Ubuntu
  2. How do I change the code snippet to make use the APXS script there

Thank you so much for Your time

How to call executable using system call from apache module type_checker hook?

I developed one module in C and integrated it in apache server using apache extension tool(apxs).

I am able to run executable using system call in background when calling it from post_config hook.

Now I want to run executable using system call only when particular mime type like .mp4 video is called on apache. I am trying to execute same system() function on executable from type_checker hook but it is not working.

So how can I call executable using system call from apache module type_checker hook?

NTLM Installation : apxs Error command failed with rc = 65535

Redhat 6.5
Apache 2.2.15
PHP 5.3

Tried to install ntlm using these steps :
http://modntlm.sourceforge.net/

Error occured:

cp : cannot stat `mod_ntml.so` : No such file or directory
apxs:Error : command failed with rc=65535
make : **** [install ] Error 1

Followed these steps but the error didn't resolve :
http://tutorials.section6.net/home/setting-up-apache-2-2-x-for-ntlm-authentication-using-mod-ntlm2

How can I fix this?