Version 5.0

AdvertPro - Apache + mod_proxy_ajp + Tomcat Installation


Linux Distributions

AdvertPro is designed to work best with CentOS and Red Hat Enterprise Linux. All of our development, testing and support staff training is done with CentOS. For this reason, we strongly recommend that you choose one of these supported Linux distributions. In fact, these instructions presume that you will be taking our advice!

Hardware Sizing

Need help deciding what type of server or how many servers to get? Check out our system administrators guide for some guidance. There is also our clustering guide which explains how to scale out AdvertPro and handle failover. If you still have questions, please contact technical support and they'll be happy to guide you in the right direction.

Step #1: Download Files


  1. Open a browser window to:
  2. Enter your Customer ID and E-mail Address into the form.
  3. Select the operating system your server is running from the Platform list box.
  4. Select the Install package for a clean installation from the Package list box.
  5. Click on the Download Package button to proceed.
  6. Check your e-mail and you should receive an e-mail with a download link within a few minutes.

Tip Tip

If you download the install package on Windows, depending upon the browser you use, the file may be renamed from advertpro-{version}.war to advertpro-{version}.zip since WAR files are essentially ZIP files so you may need to rename the file back to advertpro-{version}.war after downloading if this occurs!

Apache 2.x + mod_proxy_ajp

yum install httpd

Java Development Kit (JDK 7)

  1. Open a browser window to:
  2. Click on the Java Download graphic for Java Platform (JDK).
  3. Click on the Accept License Agreement radio button on the next page.
  4. Then click on the RPM download link for Linux x86 if you have a 32-bit system or Linux x64 if you have a 64-bit system.

Java Libraries

  1. Download the JavaMail 1.4 library from
  2. Download the JAF 1.1 library from

MySQL 5.x

Downloading and installing MySQL is as easy as running the following command:

yum install mysql mysql-server

MariaDB is also supported provided that you use the MyISAM storage engine. In the future we may support the newer Aria storage engine. However, at the time of writing we do not recommend using Aria in a production environment as it has not been tested sufficiently.

Another option is TokuDB, which we highly recommend for customers with high-traffic deployments. In fact, you can use TokuDB with either MySQL or MariaDB. Please make sure that you are using AdvertPro 4.0 or newer versions, however, as previous versions are not fully optimized for the TokuDB storage engine. It's also strongly recommended that you use SSD disks with TokuDB, preferably in a RAID10 configuration with 4-6 disks to get the best possible performance.

MySQL Connector/J JDBC Driver

  1. Open a browser window to one of the following, depending on your chosen version of MySQL:
  2. Download the platform independent Compressed TAR Archive package.

Tomcat 7.0

  1. Open a browser window to:
  2. Scroll down to the Binary Distributions section.
  3. Download the package labeled Core: tar.gz

Step #2: Installation

Java Development Kit


rpm -i jdk-{version}-linux-i586.rpm


rpm -i jdk-{version}-linux-x64.rpm


mv apache-tomcat-{version}.tar.gz /usr/local
cd /usr/local
tar -xzvf apache-tomcat-{version}.tar.gz
mv apache-tomcat-{version} tomcat
rm -rf apache-tomcat-{version}.tar.gz
cd tomcat
chmod 755 bin/*.sh
cd webapps
rm -rf *
mkdir ROOT

Tomcat APR Library

yum install apr-devel
yum install gcc
yum install make
yum install zlib-devel
cd /usr/local/tomcat/bin
tar -xzf tomcat-native.tar.gz
cd tomcat-native*
cd jni/native
./configure --with-java-home=/usr/java/latest --with-apr=/usr/bin/apr-1-config --with-ssl=no
make install

Java Libraries

unzip javamail-{version}.zip
cp javamail-{version}/mail.jar /usr/local/tomcat/lib/mail.jar
unzip jaf-{version}.zip
cp jaf-{version}/activation.jar /usr/local/tomcat/lib/activation.jar

MySQL Connector/J JDBC Driver

tar -xzvf mysql-connector-java-{version}.tar.gz
cd mysql-connector-java-{version}
cp mysql-connector-java-{version}-bin.jar /usr/local/tomcat/lib/mysql.jar


cp advertpro-{version}.war /usr/local/tomcat/webapps/ROOT
cd /usr/local/tomcat/webapps/ROOT
/usr/java/latest/bin/jar -xf advertpro-{version}.war
rm -f advertpro-{version}.war

Step #3: Configuration

Environment Variables

The following environment variables should be added to the /etc/profile file.

export JAVA_HOME=/usr/java/latest
export PATH=$PATH:$JAVA_HOME/bin

You either need to log out and log back in or run those export commands at this point, which will add those environment variables to your shell session.

MySQL Settings

Replace the entire contents of the /etc/my.cnf with the following recommended configuration:

port = 3306
socket = /var/lib/mysql/mysql.sock

port = 3306
socket = /var/lib/mysql/mysql.sock
datadir = /var/lib/mysql
max_connections = 384
key_buffer_size = 64M
table_open_cache = 256
thread_cache_size = 8
bulk_insert_buffer_size = 16M
join_buffer_size = 1M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
sort_buffer_size = 4M
max_allowed_packet = 16M
max_heap_table_size = 32M
tmp_table_size = 32M
query_alloc_block_size = 16384
query_cache_limit = 1M
query_cache_size = 32M
query_cache_type = 1
query_prealloc_size = 16384
myisam_sort_buffer_size = 64M
server-id = 1
symbolic-links = 0

basedir = /var/lib
user = mysql

err-log = /var/log/mysqld.log
pid-file = /var/run/mysqld/

max_allowed_packet = 16M


key_buffer = 128M
read_buffer = 2M
write_buffer = 2M
sort_buffer = 128M

key_buffer = 128M
read_buffer = 2M
write_buffer = 2M
sort_buffer = 128M


Note Note

These settings are for MySQL 5.5 and may require modifications to work with older versions of MySQL. Please contact technical support for configuration guidance if needed.

Apache mod_proxy_ajp

Create the /etc/httpd/conf.d/proxy_ajp.conf file if it does not exist and replace its content with the following:

<IfModule mod_proxy_ajp.c>
  ProxyPass / ajp://localhost:8009/

Tomcat Environment

Edit /usr/local/tomcat/bin/ and add the following settings after the comments/instructions at the top.


Read the instructions contained within the settings to properly set the -Xmx, -Xms, -XX:NewSize, -XX:MaxNewSize and -XX:ParallelGCThreads options -- failure to do so will likely result in degraded performance.

# Tomcat Home.

# Java Home.

# Change -Xms and -Xms if necessary to allocate more or less memory.
# It is important that they have the same value for optimal performance.
# Note that on some operating systems you may need to increase the value of
# -Xss to 512k or higher (do not exceed 1024k) if you experience stability
# problems or start seeing stack overflow exceptions in your application
# server logs.
# If you've changed -Xms and -Xms, you should change -XX:NewSize and
# -XX:MaxNewSize to have values equal to half of the -Xms and -Xmx
# values.
# Suggested values based on available physical server memory (RAM):
#  2 GB RAM    -Xms1024m     -Xmx1024m     -XX:NewSize=512m     -XX:MaxNewSize=512m
#  4 GB RAM    -Xms2048m     -Xmx2048m     -XX:NewSize=1024m    -XX:MaxNewSize=1024m
#  8 GB RAM    -Xms4096m     -Xmx4096m     -XX:NewSize=2048m    -XX:MaxNewSize=2048m
# 16 GB RAM    -Xms8192m     -Xmx8192m     -XX:NewSize=4096m    -XX:MaxNewSize=4096m
# 32 GB RAM    -Xms16384m    -Xmx16384m    -XX:NewSize=8192m    -XX:MaxNewSize=8192m
CATALINA_OPTS="$CATALINA_OPTS -server -Xms512m -Xmx512m -Xss256k -XX:+DisableExplicitGC"
CATALINA_OPTS="$CATALINA_OPTS -XX:NewSize=256m -XX:MaxNewSize=256m"

# If you're using a multi processor system, uncomment the following
# options and set the value of -XX:ParallelGCThreads equal to the
# number of physical CPU cores that are in your system.
CATALINA_OPTS="$CATALINA_OPTS -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=80"
CATALINA_OPTS="$CATALINA_OPTS -XX:SurvivorRatio=128 -XX:MaxTenuringThreshold=0"

# APR Connector JNI Library
CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib"

# Uncomment the following options to help debug garbage collection
# related performance problems.
CATALINA_OPTS="$CATALINA_OPTS -verbose:gc -Xloggc:/usr/local/tomcat/logs/gc.txt -XX:+PrintGCDetails"

# Java Options.
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"

# Raise open file limit and stack size.
ulimit -n 524288
ulimit -s 2048

Tomcat Logging

Edit the /usr/local/tomcat/conf/ file and change the following log handlers from INFO to SEVERE level: = SEVERE = SEVERE = SEVERE = SEVERE
java.util.logging.ConsoleHandler.level = SEVERE

Tomcat Configuration

Replace the entire contents of the /usr/local/tomcat/conf/server.xml with the following recommended configuration:

<?xml version="1.0" encoding="utf-8"?>

<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

    <Resource name="UserDatabase" auth="Container"
              description="User database that can be updated and saved"
              pathname="conf/tomcat-users.xml" />

  <Service name="Catalina">

    <Connector protocol="org.apache.coyote.ajp.AjpAprProtocol"

    <Engine defaultHost="" name="Catalina">

      <Host name="" appBase="webapps" unpackWARs="true">

        <Context docBase="ROOT" path="" privileged="false" swallowOutput="true" />


      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>




Warning Warning

It is very important to set the proxyName and proxyPort settings if you intend to use AJAX zone code to allow AdvertPro to pass user session cookies from the domain of your web site(s) to the domain of the ad server.

Tip Tip

For high traffic sites, you should increase the values of the maxThreads and pollerSize options. If you have 8GB of RAM it's suggested to increase them to 2048 and 8192. When you have 16GB of RAM or more it's recommended to set them to 8192 and 32768. As a rule, the pollerSize should always be four times the maxThreads

Tomcat Startup

Create /etc/rc.d/init.d/tomcat and place the following content in it:

# Startup script for the Tomcat Web Server
# chkconfig: 345 92 16
# description: Tomcat is a World Wide Web server.  It is used to serve \
#              HTML, JSP, and servlets, and CGI if needed.
# processname: java


case "$1" in
        rm -rf $CATALINA_HOME/work
        mkdir $CATALINA_HOME/work
        sleep 30
        killall -9 java
        sleep 2
        rm -rf $CATALINA_HOME/work
        mkdir $CATALINA_HOME/work
        sleep 30
        killall -9 java
        sleep 2
        echo $"Usage: tomcat {start|restart|stop}"
        exit 1

exit 0

Run Levels

The key thing here is that MySQL should start at level 2 while Apache and Tomcat should start at level 3 so that MySQL is started before Apache and Tomcat start.

chmod 755 /etc/rc.d/init.d/httpd
/sbin/chkconfig --add httpd
/sbin/chkconfig --level 345 httpd on
/sbin/chkconfig --list httpd

chmod 755 /etc/rc.d/init.d/mysqld
/sbin/chkconfig --add mysqld
/sbin/chkconfig --level 2345 mysqld on
/sbin/chkconfig --list mysqld

chmod 755 /etc/rc.d/init.d/tomcat
/sbin/chkconfig --add tomcat
/sbin/chkconfig --level 345 tomcat on
/sbin/chkconfig --list tomcat

Firewall Configuration

AdvertPro needs the following ports to be open in your firewall in order to function properly:

Port NumberProtocolAllow InputAllow OutputClient/Source AddressDestination AddressUsed By

Assuming you will be using the iptables firewall, simply replace the entire contents of the /etc/sysconfig/iptables file with the following:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

After making that change you will need to restart iptables, which can be done with the following command:

/etc/rc.d/init.d/iptables restart

Network Configuration

Handling a huge number of connections may not work smoothly out of the box. You generally have to do some optimizations to the TCP/IP settings. Start with the following settings and optimize further if needed, but in most cases they'll do fine as-is.

First, you can hot-deploy the following optimized TCP/IP settings by running these commands:

/sbin/sysctl -w net.ipv4.tcp_max_syn_backlog=4096
/sbin/sysctl -w net.ipv4.tcp_syncookies=1
/sbin/sysctl -w net.ipv4.tcp_synack_retries=5
/sbin/sysctl -w net.ipv4.tcp_fin_timeout=15
/sbin/sysctl -w net.core.rmem_default=104448
/sbin/sysctl -w net.core.wmem_default=104448
/sbin/sysctl -w net.core.wmem_max=12582912
/sbin/sysctl -w net.core.rmem_max=12582912
/sbin/sysctl -w net.ipv4.tcp_rmem="10240 87380 12582912"
/sbin/sysctl -w net.ipv4.tcp_wmem="10240 87380 12582912"
/sbin/sysctl -w net.ipv4.tcp_mem="8388608 8388608 8388608"
/sbin/sysctl -w net.core.netdev_max_backlog=2500
/sbin/sysctl -w fs.file-max=6315922
/sbin/sysctl -w net.netfilter.nf_conntrack_max=33554432
/sbin/sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
/sbin/sysctl -w net.ipv4.tcp_window_scaling=1

Then to make these changes permanent the following settings can be added to the end of your /etc/sysctl.conf file:

# Controls the use of TCP syncookies
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 5

# Reduce FIN_WAIT state time
net.ipv4.tcp_fin_timeout = 15

# Larger TCP memory
net.core.rmem_default = 104448
net.core.wmem_default = 104448
net.core.wmem_max = 12582912
net.core.rmem_max = 12582912
net.ipv4.tcp_rmem = 10240 87380 12582912
net.ipv4.tcp_wmem = 10240 87380 12582912
net.ipv4.tcp_mem = 8388608 8388608 8388608
net.core.netdev_max_backlog = 2500
fs.file-max = 6315922

# Larger Connection Table
net.netfilter.nf_conntrack_max = 33554432

# Misc TCP adjustments
net.ipv4.tcp_moderate_rcvbuf = 1
net.ipv4.tcp_window_scaling = 1

Step #4: Startup


/etc/rc.d/init.d/mysqld start


/etc/rc.d/init.d/httpd start


/etc/rc.d/init.d/tomcat start

Step #5: Finishing Up

MySQL Database

Log in to the MySQL client and execute the following SQL queries to create the AdvertPro database and user to access it.

mysql -u root

CREATE DATABASE advertpro CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON advertpro.* TO advertpro@"localhost" IDENTIFIED BY 'changeme';
GRANT ALL PRIVILEGES ON advertpro.* TO advertpro@"localhost.localdomain" IDENTIFIED BY 'changeme';

GeoIP Database

If you have purchased a subscription to the GeoIP Country or GeoIP City database, you should install that prior to running the AdvertPro setup utility.

  1. GeoIP Country Installation
  2. GeoIP City Installation

AdvertPro Setup

  1. Open a browser window to:
  2. Follow the setup utility instructions.


  1. By default AdvertPro will only establish up to 15 persistent connections to MySQL. This is usually not enough for a high traffic deployment. Too many connections can be bad though as MySQL will use too much memory. We suggest increasing the Maximum Connections setting on the Settings > Basic > Database page to 100 for high traffic deployments, which should be sufficient for most customers.
  2. MySQL load can also be greatly reduced by enabling in-memory user sessions, which is available as an option on the Settings > Basic > Server page in the User Sessions section.
  3. At this point, you may also wish to read our system administrators guide which covers important topics such as backups, logging, monitoring and more.
  4. One final thing you may want to do is add an SSL certificate to secure control panel access, which is described in our companion SSL integration guide.