CentOS 64 Server, zpanel, tomcat


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 installer-10-1-0-centos-64.sh.x https://github.com/zpanel/zpanelx/releases/download/10.1.0_orig/installer-10-1-0-centos-64.sh.x
- make it executable
# chmod +x installer-10-1-0-centos-64.sh.x
- install pre-requiered packages
# yum install ld-linux.so.2 curl
- run the installer
# ./installer-10-1-0-centos-64.sh.x
The server will reboot.
Install Java
Initial informations from tecadmin.net
- 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 tecadmin.net
- go to /opt directory
# cd /opt/
- download tomcat 7
http://tomcat.apache.org/download-70.cgi
# wget http://apache.sunsite.ualberta.ca/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.tar.gz
- unzip it
# tar xzf apache-tomcat-7.0.52.tar.gz
- start tomcat
# cd apache-tomcat-7.0.52
# ./bin/startup.sh
- test tomcat web server : http://youraddress.com:8080
Configure Apache + tomcat
Initial informations from tomcat.apache.org
Tomcat side
- go to /etc/httpd/conf
# cd /etc/httpd/conf/
- create the file workers.properties
# nano workers.properties
NB: if nano is not installed, you can install it this way :
# yum install nano
- file content
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
Apache side
We need to compile the mod_jk.so apache module.
Build the mod_jk.so module
- go to your home directory
# cd ~
- download source from here : http://tomcat.apache.org/download-connectors.cgi
# wget http://apache.mirror.iweb.ca//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.39-src.tar.gz
- 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 mod_jk.so is in apache-2.0 directory.
- copy the generated module in apache module directory
# cp apache-2.0/mod_jk.so /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/mod_jk.so
# Where to find workers.properties
JkWorkersFile /etc/httpd/conf/workers.properties
# 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 http://mydomain.com/examples/ 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