# DeviceAtlas Apache2 Module #
Quick Start
There are 3 important steps for the usage of the DeviceAtlas C API and
Apache module.
- Make the API & module
- Install the shared libraries
- Configure Apache (minimum supported: 2.0, recommended: 2.4 and onwards).
Optional:
- Enable the client side component
** Dependencies **
- Apache web server headers
- Apr and Apr Utils (Apache Portable Runtime Library)
(Example for Red Hat based operating systems, the needed package
is httpd-devel (it will install related apr-devel and apr-util-devel packages),
for Debian based ones, the name is apache2-threaded-dev (it will install
related libapr1-dev and libaprutil1-dev packages). For ubuntu you can install
package apache2-dev for apache headers and include files. If your Apache headers
and/or Apr/Apr-util library and headers are located in custom locations you
have to set those cmake environment variables :
- APACHE_INCLUDE_DIR=<path to apache/httpd headers folder>
- APR_INCLUDE_DIR=<path to apr/apr-util headers folder>
- APR_LIBRARY=<path to apr library>
For example :
```shell
cmake ...
-DAPACHE_INCLUDE_DIR=/home/test/httpd/include
-DAPR_INCLUDE_DIR=/home/test/apr/include
-DAPR_LIBRARY=/home/test/apr/lib/libapr-1.so
```
32/64bit:
- This Apache module must be built according to Apache web server itself
(If Apache is 64 bits compliant, the module has to be too...)
** Step 1 **
a) EXTRACT PACKAGE
b) cmake . (or cmake -DCMAKE_SKIP_INSTALL_RPATH=1 if you do not wish to
link the Apache module to the current package location)
$ unzip deviceatlas-enterprise-c-{version}.zip
$ cd deviceatlas-enterprise-c-{version}
$ cmake .
$ make
$ make install
$ sudo ldconfig
or on RedHat/CentOS
$ sudo ldconfig /usr/local/lib64 (on 64 bits systems)
** Step 2 **
$ cd Apache-Mod
$ sudo make -f GNUMakefile
or if the Apache Extension Tool has a particular naming like on RedHat/CentOS
servers, it is possible to override the APXS variable as follow
$ sudo make -f GNUMakefile APXS=apxs
Module directory in Ubuntu/Debian:
/usr/lib/apache2/modules
Module directory in RedHat/CentOS:
/usr/lib64/httpd/modules
or
/usr/lib/httpd/modules (on 32 bits sytems)
** Step 3 **
Apache must be configured to load the DeviceAtlas module. The module is then
configured in the Virtual Host.
# Add to httpd.conf
"LoadModule da_module /PATH/TO/MODULE/mod_deviceatlas.so"
# Enable Module in virtual host
DA On
# (Optional)
# DAEnvironmentVars On (Device / Carrier properties set as environment variables
# by default they are set as request headers)
# (Optional)
# DaCacheSize 10000 (Set the number of cache entries available for the Device api
# by default is off)
DAJsonFilePath /PATH/TO/JSON (If DeviceAtlas support)
DACarrierApiFilePath /PATH/TO/DATA FILE (If Carrier Identification support)
=> For more information/options check the apache2/virtualhost.*.conf files
** Step 4 **
RESTART APACHE!
NOTE:
The Apache module prefixes all property names with "X-DeviceAtlas-" when
setting the properties in the request headers. For example the property
"mobileDevice" becomes a header called "X-DeviceAtlas-mobileDevice".
A PHP sample application is available for a test inside the ExampleApp,
you can copy those files to your DocumentRoot and try /index.php
** Common Errors **
When building Apache module if you see errors like
```
-- Could NOT find APACHE (missing: APACHE_INCLUDE_DIR)
-- Could NOT find APR (missing: APR_INCLUDE_DIR)
-- Could NOT find APR_UTIL (missing: APR_UTIL_INCLUDE_DIR)
APACHE module requires APR and APACHE headers - not found
```
You might have wrong paths set for Apache headers and include files,
please read Dependencies section for more details.
** Mod Proxy **
It is possible to use the module with the Apache builtin mod proxy module.
Typical usage would be to have one server having the DeviceAtlas module
proxying to one or more servers, the DeviceAtlas properties will be send
as request headers to these.
In an usual JSON setting and device clients reaching the servers, it is
however not always possible to send all properties due to request headers
size limits.
It is then recommended to both set LimitRequestFieldSize to a higher value
and using the DaIncludeHeader for each necessary property the servers
need to process for the business logic to operate.
```shell
...
DaIncludeHeader primaryHardwareType
DaIncludeHeader vendor
DaIncludeHeader model
DaIncludeHeader devicePixelRatio
...
```
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_ Copyright (c) DeviceAtlas Limited 2024. All Rights Reserved. _
_ https://deviceatlas.com _