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')
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.
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
APXSenvironment variable to the location of the Apache
apxsscript 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-expressscript with the
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)
I'm doing all of this on a server running UBuntu 12.04LTS if it helps. My question at the end are the following
- Where is the APXS located usually in Ubuntu
- How do I change the code snippet to make use the APXS script there
Thank you so much for Your time