Home Backend Development PHP Tutorial java跟php异构系统的配置

java跟php异构系统的配置

Jun 13, 2016 pm 01:08 PM
apache conf linux tomcat

java和php异构系统的配置
java和php异构系统的配置(横向扩展用)(日期:2010-08-25)

1、首先安装并配置好apache和php5,并自己测试成功。


2、apache tomcat 整合

windows 和linux步骤类似,只写linux

首先linux下载java,最好是jdk1.6版本或以上。安装java环境。网上都有介绍。假设linux机器的ip是 192.168.1.2。

然后,下载tomcat6.0,安装tomcat,然后 执行tomcat/bin/startup.sh ,然后随便找台机器进入浏览器,http://192.168.1.2:8080/测试,如果看到猫的页面,就ok。

下面是整合apache和tomcat

第1步:下载jk这个动态连接库,进入http://www.apache.org/dist/tomcat/tomcat- connectors/jk/binaries/
然后进入适当的目录,根据系统和apache的版本下载。

第2步:把下载来的文件mod_jk***.so放到$apache_home/modules下

第3步:打开tomcat/conf/server.xml
找到这一行
在这一行的下面加一行并保存

显然,modJk="D:\Apache2\modules\mod_jk.so"双引号里的内容应该根据操作系统从根目录到 mod_jk***.so的完整路径和文件名。

第4步:然后,linux下
进入tomcat/bin目录分别执行以下命令重启tomcat6

./catalina.sh stop
./catalina.sh start

第5步:正常来说,进入tomcat/conf下会发现多了两个目录,auto和jk目录
这时进入auto目录,打开里面的文件,把里面的内容复制,
进入linux的apache/conf目录,打开httpd.conf
把刚才的内容复制到httpd.conf文件的最后,其实内容就是两个
一个是加载一个模块
一个是指定浏览器访问哪些目录下的文件apche会主动寻找tomcat。

第6步:再加一句
DirectoryIndex index.html index.php index.jsp
注意,如果加这句之前先在httpd.conf文件寻找已经存在的DirectoryIndex指令行并先注释掉,免得冲突

第7步:保存httpd.conf,重启apache,通常要进入apache/bin所在目录,执行
./apachectl stop
./apachectl start
如果启动不起来,说明httpd.conf文件有错误,需要自行调整。



现在,如果浏览器输入
http://192.168.1.2/examples/jsp/jsp2/tagfiles/hello.jsp
会正确显示jsp页面。
注意:只要浏览器输入url时不特别指定端口,则就是访问远程服务器的80端口,所以现在
可以知道页面一定是通过apache转给tomcat的,因为tomcat在没修改配置时只监听8080端口,而不是80端口。
而apache默认只监听80端口。
而tomcat现在也可以监听8080端口并给出反应,
浏览器输入
http://192.168.1.2:8080/examples/jsp/jsp2/tagfiles/hello.jsp
能看到同样结果

而http://192.168.1.2/phpinfo.php
也能访问php程序。

可以用防火墙屏蔽掉linux的8080端口,让tomcat只接收本机的apache的请求转发即可。
当然,更好的做法是只开放80和22端口,别的都禁止,因为tomcat还有别的端口开放。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages ​​and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

git software installation git software installation Apr 17, 2025 am 11:57 AM

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

How to set shortcut keys for sublime How to set shortcut keys for sublime Apr 16, 2025 am 09:15 AM

To set the shortcut keys for Sublime Text, follow these steps: Open the shortcut key settings file Key Bindings - User. Add shortcut key settings using the format { "keys": ["key combination"], "command": "command" }. Save changes. Reload the shortcut key settings for the changes to take effect.

See all articles