Ubuntu12.04 on MOD_JK integrating Java projects with PHP projects

Source: Internet
Author: User
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:

    1. os:ubuntu12.04
    2. tomcat6.0.16
    3. Jdk1.7.0_03
    4. apache2.2.22
    5. Mod_jk
    6. 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:

  1. tomcat6.0.16 installation: http://tomcat.apache.org/Direct download Decompression can
  2. JDK1.7.0_03 installation: Refer to Network Installation JDK method (http://blog.csdn.net/ritterliu/article/details/7525412)
  3. apache2.2.22 Installation: $sudo apt-get install Apache2
  4. installation of MOD_JK: $sudo apt-get Install LIBAPACHE2-MOD-JK
  5. the configuration of MOD_JK,MOD_JK is mainly in the following three places:
    1. 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
    2. 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"
    3. 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.
    4. 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:)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.