There are many different distributions of Linux based operating systems. Every distribution has its own recommended way of installing and configuring packages. Some parts of these instructions assume that you are working with a Linux distribution that has RPM support, which includes the popular CentOS and Red Hat Linux. For other distributions, you may need to refer to their specific Java and MySQL installation instructions.
If you are running Apache Web Server to host other web sites or applications on the same server as AdvertPRO is going to be installed on, please follow these alternate instructions for configuring Apache Tomcat to connect with Apache Web Server using the mod_proxy_ajp module: Apache + mod_proxy_ajp + Tomcat Installation
In most cases your distribution of Linux probably already has MySQL included with it. We recommend using that version of MySQL rather than trying to remove it and install a different version. The reason being that the developer of your distribution has certified that version of MySQL to be stable with it. However, if you still wish to download MySQL and install it you may obtain it using the following instructions.
chmod 755 jdk-<version>-linux-x64-rpm.bin
./jdk-<version>-linux-x64-rpm.bin
rpm -i MySQL-server-community-<version>.x86_64.rpm
rpm -i MySQL-client-community-<version>.x86_64.rpm
rpm -i MySQL-devel-community-<version>.x86_64.rpm
rpm -i MySQL-shared-community-<version>.x86_64.rpm
rpm -i MySQL-shared-compat-<version>.x86_64.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
yum install apr-devel
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
make install
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
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
export JAVA_HOME=/usr/java/latest
export PATH=$PATH:$JAVA_HOME/bin
Replace the entire contents of the /etc/my.cnf with the following recommended configuration:
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
bind-address = 127.0.0.1
datadir = /var/lib/mysql
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
set-variable = max_connections=384
set-variable = key_buffer=64M
set-variable = table_cache=256
set-variable = sort_buffer=4M
set-variable = record_buffer=1M
set-variable = max_allowed_packet=16M
set-variable = myisam_sort_buffer_size=64M
set-variable = thread_cache=8
server-id = 1
old_passwords = 1
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqldump]
quick
set-variable = max_allowed_packet=16M
[mysql]
no-auto-rehash
[isamchk]
set-variable = key_buffer=128M
set-variable = sort_buffer=128M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[myisamchk]
set-variable = key_buffer=128M
set-variable = sort_buffer=128M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[mysqlhotcopy]
interactive-timeout
Edit /usr/local/tomcat/bin/catalina.sh and add the following after the comments/instructions at the top.
# Tomcat Home.
CATALINA_HOME="/usr/local/tomcat"
# Java Home.
JAVA_HOME="/usr/java/latest"
#
# 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 -Xss128k -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 processors that are in your system.
#
#CATALINA_OPTS="$CATALINA_OPTS -XX:+UseParNewGC -XX:ParallelGCThreads=4"
#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 -Dsun.net.inetaddr.ttl=28800 -Dsun.net.inetaddr.negative.ttl=60"
#
# Raise open file limit and stack size.
#
ulimit -n 524288
ulimit -s 2048
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.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
acceptCount="128"
connectionTimeout="10000"
disableUploadTimeout="false"
enableLookups="false"
maxKeepAliveRequests="100"
keepAliveTimeout="15000"
maxThreads="512"
pollTime="2000"
pollerSize="2048"
useSendfile="true"
sendfileSize="1024"
port="80"
redirectPort="443"
URIEncoding="UTF-8"/>
<Engine defaultHost="localhost" name="Catalina">
<Host name="localhost" appBase="webapps" unpackWARs="true">
<Context docBase="ROOT" path="" privileged="false" swallowOutput="true" />
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Engine>
</Service>
</Server>
Create /etc/rc.d/init.d/tomcat using the following recommended settings.
#!/bin/bash
#
# 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
CATALINA_HOME=/usr/local/tomcat
case "$1" in
start)
rm -rf $CATALINA_HOME/work
mkdir $CATALINA_HOME/work
$CATALINA_HOME/bin/startup.sh
;;
restart)
$CATALINA_HOME/bin/shutdown.sh
sleep 45
killall -9 java
sleep 2
rm -rf $CATALINA_HOME/work
mkdir $CATALINA_HOME/work
$CATALINA_HOME/bin/startup.sh
;;
stop)
$CATALINA_HOME/bin/shutdown.sh
sleep 45
killall -9 java
sleep 2
;;
*)
echo $"Usage: tomcat {start|restart|stop}"
exit 1
esac
exit 0
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
AdvertPRO needs the following ports to be open in your firewall in order to function properly:
Port Number | Protocol | Allow Input | Allow Output | Client/Source Address | Destination Address | Used By |
---|---|---|---|---|---|---|
25 | TCP | Yes | Yes | Any | Any | SMTP |
80 | TCP | Yes | Yes | Any | Any | HTTP |
443 | TCP | Yes | Yes | Any | Any | HTTPS |
3306 | TCP | Yes | Yes | localhost | localhost | MySQL |
9000 | TCP | No | Yes | localhost | websvc1.advertpro.com websvc2.advertpro.com | AdvertPRO |
9001 | TCP | No | Yes | localhost | websvc1.advertpro.com websvc2.advertpro.com | AdvertPRO |
9002 | TCP | No | Yes | localhost | websvc1.advertpro.com websvc2.advertpro.com | AdvertPRO |
9003 | TCP | No | Yes | localhost | websvc1.advertpro.com websvc2.advertpro.com | AdvertPRO |
9004 | TCP | No | Yes | localhost | websvc1.advertpro.com websvc2.advertpro.com | AdvertPRO |
9005 | TCP | No | Yes | localhost | websvc1.advertpro.com websvc2.advertpro.com | AdvertPRO |
Failure to open the aforementioned ports in your firewall will cause the AdvertPRO setup utility to abort.
/etc/rc.d/init.d/mysql start
/etc/rc.d/init.d/tomcat start
Log in to the MySQL client of your choosing and execute the following SQL queries to create the AdvertPRO database and user to access it.
CREATE DATABASE advertpro;
GRANT ALL PRIVILEGES ON advertpro.* TO advertpro@"localhost" IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON advertpro.* TO advertpro@"localhost.localdomain" IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Keep in mind that the database will be created using the default MySQL character set, which is specified by the character_set_system option in the my.cnf configuration file. For older versions of MySQL the option is named character_set instead. By default MySQL uses the Latin1 character set, so if you wish to use UTF-8 to support non-Latin1 characters create the MySQL database using this command unless you already changed the default MySQL character set to UTF-8:
CREATE DATABASE advertpro CHARACTER SET utf8 COLLATE utf8_general_ci;
When the AdvertPRO setup utility asks you for the JDBC URL you should changed it to specify that you want to use UTF-8 unless again you already changed the default MySQL character set to UTF-8 as the driver will always use the default MySQL character set regardless of the character set of your database:
jdbc:mysql://localhost:3306/advertpro?useUnicode=true&characterEncoding=UTF-8
If you have purchased the GeoIP Country or City database, you should install that prior to running the AdvertPRO setup utility.