Geek Mag, Le petit journal du geek

Skip to: Content | Sidebar | Footer

CentOS 64 Server, zpanel, tomcat

22 mars 2014 - 22 h 01 min | CentOS, GNU/Linux, Web Server | Par: Léo

zpanel   300px-Tomcat-logo.svg

zpanel is a all-in-one solution for installing, configuring & managing a complete linux web server. It provide PHP, MySQL, FTP server, mail server, web mail interface, DNS server and a very friendly web configuration panel.

Unfortunately, it does not provide any java servlet server, like tomcat. This is a quick « how to » install a web server using zpanel and tomcat.

Install zpanel

initial informations from zpanel documentation

- download installer
# wget -O

- make it executable
# chmod +x

- install pre-requiered packages
# yum install curl

- run the installer
# ./

The server will reboot.

Install Java

Initial informations from

- check java installation
# java -version

If java is installed and up to date, go to Install tomcat.

- go to /opt directory
# cd /opt/

- download last JDK version tar.gz here

- unzip it
# tar xzf jdk-7u51-linux-i586.tar.gz

- install Java
# cd /opt/jdk1.7.0_51/
# alternatives --install /usr/bin/java java /opt/jdk1.7.0_51/bin/java 2
# alternatives --config java

- choose the version you just download.

- check Java version again
# java -version

- setup Environment Variables
# export JAVA_HOME=/opt/jdk1.7.0_51
# export JRE_HOME=/opt/jdk1.7.0_51/jre
# export PATH=$PATH:/opt/jdk1.7.0_51/bin:/opt/jdk1.7.0_51/jre/bin

Install tomcat

Initial informations from

- go to /opt directory
# cd /opt/

- download tomcat 7
# wget

- unzip it
# tar xzf apache-tomcat-7.0.52.tar.gz

- start tomcat
# cd apache-tomcat-7.0.52
# ./bin/

- test tomcat web server :

Configure Apache + tomcat

Initial informations from

Tomcat side

- go to /etc/httpd/conf
# cd /etc/httpd/conf/

- create the file
# nano

NB: if nano is not installed, you can install it this way :
# yum install nano

- file content
# Define 1 real worker using ajp13

# Set properties for worker1 (ajp13)

Apache side

We need to compile the apache module.

Build the module

- go to your home directory
# cd ~

- download source from here :
# wget

- unzip it
# tar xzf tomcat-connectors-1.2.39-src.tar.gz

- go to ./tomcat-connectors-1.2.39-src/native
# cd tomcat-connectors-1.2.39-src/native

- configure the build
# ./configure --with-apxs=/usr/sbin/apxs

- make the build
# make

The wanted is in apache-2.0 directory.

- copy the generated module in apache module directory
# cp apache-2.0/ /etc/httpd/modules/

- go to /etc/httpd/conf
# cd /etc/httpd/conf/

Configure Apache

- go back to /etc/httpd/conf
# cd /etc/httpd/conf/

- create the file tomcat.conf
# nano tomcat.conf

- file content
# Load mod_jk module
LoadModule jk_module modules/

# Where to find
JkWorkersFile /etc/httpd/conf/

# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/httpd/mod_jk.shm

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/httpd/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

- edit httpd.conf
# nano httpd.conf

- add this line add the very end of the file (after zpanel include)
Include conf/tomcat.conf

Tip: keep pressing ctrl+V to reach end of file faster

- restart apache server to be sure there is no loading error
# httpd -k restart

Configure zpanel

to configure a domain name to use tomcat for some of its pages, you need to add a JkMount custom entry in its Virtual Host.

- log-in in zpanel
- go to Admin >> Module Admin >> Apache Config
- in the bottom of the page, select the concerned domain name in « Override a Virtual Host Setting »
- click « Select Vhost »

In Custom Entry, you could enter something like that:

- any url that start with will be forwarded to tomcat (this is the default example page of tomcat)
JkMount /examples worker1
JkMount /examples/* worker1

- all url will be forwarded to tomcat
JkMount * worker1


Commentaire de hfazla
Publié le 9 mars 2015 à 12 h 14 min

thank you very usefull

Rédiger un commentaire