Ubuntu12.04 under MOD_JK integrated Java Project and PHP project
Due to the needs of the project, PHP and Java projects need to be published at the same time 80 port, this article uses MOD_JK for different project integration. Consolidate and publish the PHP project that was originally in Apatch with the Java project running under Tomcat.
Integrated platform and software versions:
- os:ubuntu12.04
- tomcat6.0.16
- Jdk1.7.0_03
- apache2.2.22
- Mod_jk
- The Java project is located at: in/home/hkr/project/sd/tomcat-6.0.14/webapps/myjavaproject ; PHP project is located in/var/www/myphpproject
The main steps are as follows:
- tomcat6.0.16 installation: http://tomcat.apache.org/Direct download Decompression can
- JDK1.7.0_03 installation: Refer to Network Installation JDK method (http://blog.csdn.net/ritterliu/article/details/7525412)
- apache2.2.22 Installation: $sudo apt-get install Apache2
- installation of MOD_JK: $sudo apt-get Install LIBAPACHE2-MOD-JK
- the configuration of MOD_JK,MOD_JK is mainly in the following three places:
- Configuring Workers.properties (Files connected to tomcat) sudo gedit/etc/libapache2-mod-jk/workers.properties, configure the following parameters:
- Workers.tomcat_home=/home/hkr/project/sd/tomcat-6.0.14#tomcat位置
- Workers.java_home=/usr/lib/jvm/jdk1.7.0_03#java_home位置
- worker.list=ajp13_worker#自定义命名即可
- Worker.ajp13_worker.port=8009 #用8080会报错
- worker.ajp13_worker.host=192.168.1.102#本机ip地址
- Worker.ajp13_worker.type=ajp13
- worker.ajp13_worker.lbfactor=1
- worker.loadbalancer.type=lb
- worker.loadbalancer.balance_workers=Ajp13_worker
- apache2 in apache2.conf configuration: $gedit/etc/apache2/apache2.conf, add the following to the last blank of the file:
- AddType application/x-httpd-php. php. htm. html
ServerName 192.168.1.102
#JkWorkersFile/etc/libapache2-mod-jk/workers.properties (This needs to be commented, plus there will be an Apache startup times error: Jkworkersfile only allowed once)
Jklogfile/var/log/apache2/mod_jk.log
Jkloglevel Info
Jklogstampformat "[%a%b%d%h:%m:%s%Y]"
Jkoptions +forwardkeysize +forwarduricompat-forwarddirectories
Jkrequestlogformat "%w%V%T"
- Configuration of default in Apache2, $gedit/etc/apache2/sites-available/default,added before:
- Jkmount/*.jsp Ajp13_worker ( 5.1 in value of Worker.list)
- Jkmount/*.do Ajp13_worker
- .... ( the agent for other Java project projects, if the Java project is under a project, you can configure the Jkmount/java project name/* ajp13_worker, if configuration/* will also proxy all PHP scopes into Tomcat, causing the PHP project to be inaccessible, so you only need to configure the access path for the project under Tomcat.
- after configuration is complete $sudo/etc/init.d/apache2 Reload, and then $sudo/etc/init.d/apache2 Restart, you can access Tomcat and PHP projects directly via IP.
The above content has been tested in this machine VirtualBox, Welcome to Exchange:)