How do I change the APXS environment variable? - apache

How do I change the APXS environmental variable to use an apxs tool from a different location?
I am trying to install an Apache module to my MAMP installation. I can successfully install the module using $ apxs -cia mod_ftp_example.c. However, the global apxs command is using the apxs tool that comes configured for the MAC OS X pre-installed Apache server, instead of using the apxs tool located in my MAMP build.
This means that when I execute the apxs command in Terminal, the module's .so file is installed here:
/usr/libexec/apache2
This is installing the module to the Apache server that comes with the Mac, and not my MAMP build. The path to the library modules that I want to install my module's .so file into is actually here:
/Applications/MAMP/Library/modules
Now, when I execute the command $ whereis apxs, I see the apxs tool is located in /usr/sbin/apxs - again, this is inside the httpd build for the default OS X Apache server and not my MAMP server.
My theory is that if I can change the whereis location of the apxs, then I can install my modules into the correct location. So how can I change that location? I tried the following, but it doesn't seem to work :/
$ APXS=/applications/mamp/library/bin/apxs
Any ideas??? Thanks!

If your just running APXS directly you can just use the full path
i.e. instead of
apxs -cia mod_ftp_example.c
you can do
/applications/mamp/library/bin/apxs -cia mod_ftp_example.c
If your running the apache ./configure.apxs you can do
export APXS=/applications/mamp/library/bin/apxs
If your doing some other kind of script you could always change the precedence of your path:
export PATH=/applications/mamp/library/bin/:$PATH

Related

configure: error: Qtenv cannot find qmake in omnet++ installation

I'm trying to install omnetpp 5.2.1 on windows 10. But getting an error while doing ./configure command related to QT environment. I tried changing the configure.user file in omnetpp package to change the path of QT but still its not working. Here is the error:
configure:error: Qtenv cannot find qmake--maybe it is not in the path
or has some exotic name (tested names were: qmake qmake-qt5 qmake5)-
disabling Qtenv. You can try setting QT_PATH variable in
configure.user to a valid location.
qt5 might not be installed.
sudo apt install qt5-default worked for me while installing on Ubuntu 20.04.
OMNeT++ comes with all dependencies bundled. As long as you have executed the mingwenv.cmd and running from that shell, qmake should be available in the path (in tools/win64/mingw64/bin). Check if qmake.exe is present there. If not, make sure that ZIP file you have downloaded is intact. Standard windows unzip may fail on certain systems...
run ./configure WITH_QTENV = no

How to install mod_wsgi for apache2.4 with python 3.6 in centos?

I am a new to web development.I have created Django(-v 2.2) web application and I want to deploy it on my linux server(OS Centos).After installation apache2, when I was going to install libapache2-mod-wsgi-py3, it says that no package available. Is there different name for libapache2-mod-wsgi-py3 for OS Centos?
It is always recommended to install mod_wsgi directly into the python3 package using pip3.
pip3 install mod_wsgi
If you install mod_wsgi into the OS, it could cause conflict and unexpected behavior.
Do you have apache2-dev installed?
Also, for mod_wsgi it is better to go the CMMI path (configure-make-make install) in order to compile it with the correct version and load it in Apache as a module. This worked for me on Debian VPS:
To do so,
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.6.5.tar.gz
tar xvfz 4.6.5.tar.gz
cd mod_wsgi-4.6.5
whereis apxs
whereis python3
./configure --with-apxs=/usr/bin/apxs --with-python=/usr/bin/python3.5
make
sudo make install
Double check the path for apxs and python, and run make install as sudo.
When it’s all ready, check the last line of prompt results, as there will be a path to a file: /usr/lib/apache2/modules/mod_wsgi.so
To cleanup after installation, run:
make clean
If you need to build the module for a different version of Apache, you should run:
make distclean
If you have a httpd.conf file, you should edit and add this line:
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
If not, create it and paste that line, and edit /etc/apache2/apache2.conf. file, by adding this line:
Include /etc/apache2/httpd.conf
You don't need that file to configure apache, but you can create it if other software relies on it being there.
You should restart Apache and check the log
sudo tail /var/log/apache2/error.log
as there should be a line that says:
Apache/2.4.25 (Debian) mod_wsgi/4.6.5 Python/3.5 configured -- resuming normal operations

apache default httpd.conf location

This might be a dumb question, but anyway here it goes.
From the below link I could see that default config link for apache httpd2 is at
"/usr/local/apache2/conf/httpd.conf"
https://wiki.apache.org/httpd/DistrosDefaultLayout
how ever when I install httpd using yum on centos 6 and 7 config files seems to be at "/etc/httpd/conf/httpd.conf
Why doesn't yum install it to the location defined on the default distribution layout.
Default location primary httpd config file for Fedora Core, CentOS, RHEL is /etc/httpd/conf/httpd.conf
In general the path /usr/local is meant for "locally" installed packages. For a single computer that probably just means packages installed outside of the normal distribution. So I would argue a package manager like yum shouldn't even touch anything under /usr/local.
On the other hand it makes sense for the apache project to specify their default paths there, since if you download Apache directly from their site and install it you do it outside of your standard system distribution.
Standard installation of Apache 2.4 on Ubuntu puts the apache2.conf file in /home/miro/etc/apache2. You can locate the main config file using:
/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
Modify the path /usr/sbin/ to the location of the installation, if you have changed its default when installing.

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
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
Sorry for the inconvenience
Turns out I forgot to install APXS on my apache server. I simply ran the code from the terminal and it worked
sudo apt-get apache2-threaded-dev
Update
For Ubuntu 18 its (thank you #MagicLAMP)
sudo apt-get install apache2-dev
For Centos 7: (thank you #User)
yum install httpd-devel
For Centos 7:
yum install httpd-devel

How to install apxs on xampp

I have a site I'm running off an Apache server, and I want to run a python script using the server and the web browser. I'm using xampp, and I have researched that I have to use modwsgi, and I have downloaded the zip and unpacked it onto my desktop. Now using command prompt I run
setup.py install
The first time I did this, I didn't have setup tools installed for python (I have python 2.7.8 and I'm on Windows 7 64 bit), so I went ahead and downloaded that, but now when I run the command again I get the following message
RuntimeError: The 'apxs' command appears to not to be installed or is not exectuable.
Please check the list of prerequistes in the documentation for the package and install
any missing Apache httpd server packages.
How exactly do I install apxs because I don't have Apache but xampp?
I was installing apxs on XAMPP in Windows. I wrote a blog post with the complete solution (in Spanish). I basically compiled my own version of apxs. The steps were:
Install ActiveState Perl for Windows
Add C:\xampp\apache\bin to the environment variable Path
Download apxs from here
Unzip tar.gz file in C:\xampp\apache\bin.
Execute:
ppm install dmake
cd c:\xampp\apache\bin\apxs
perl Configure.pl --with-apache2=C:\xampp\apache
--with-apache-prog=httpd.exe