明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

WIN2000 + PHP + MYSQL + TOMCAT + JSP完全整合安裝手冊(cè)

[摘要]1。一個(gè)安裝好的WIN2000服務(wù)器,注意:如果預(yù)裝了IIS,請(qǐng)先將IIS服務(wù)停掉或禁用。2。下栽軟件APACHE:版本:1.3.22 ——apache_1.3.22-win32-x86.msiJDK:版本: 1.3 ——j2sdk1_3_0-win.exePHP: 版本: 4.0.4 ——php...
1。一個(gè)安裝好的WIN2000服務(wù)器,注意:如果預(yù)裝了IIS,請(qǐng)先將IIS服務(wù)停掉或禁用。

2。下栽軟件

APACHE:版本:1.3.22 ——apache_1.3.22-win32-x86.msi

JDK:版本: 1.3 ——j2sdk1_3_0-win.exe

PHP: 版本: 4.0.4 ——php4.0.4pl1-win32.zip

MYSQL: 版本:3.23.32 ——mysql-3.23.32-win.zip

TOMCAT:版本: 4.0.4 ——jakarta-tomcat-4.0.4.exe

Mod_jk:這是Jakarta組織開發(fā)的使Apache支持Tomcat的插件,比ApacheJserv更強(qiáng)大,因?yàn)锳pacheJserv

只能用在Apache上,而不能用在別的WebServer 上,Mod_jk可以和很多服務(wù)器搭配起來用。

下載地址:http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3/bin/win32/i386/

(如果在提供的網(wǎng)址內(nèi)找不到相應(yīng)的軟件,請(qǐng)?jiān)诟鞔缶W(wǎng)上軟件庫(kù)找,一般都有!或發(fā)郵件至apollo@risesun-cn.com)



3。準(zhǔn)備好足夠的干糧和水,作好反復(fù)安裝和重新啟動(dòng)的心理準(zhǔn)備,但只要細(xì)心按照要求去做,一次成功不是什么

難事!

4。做一口深呼吸,別在想MM了!開始安裝!



二、安裝開始

1。APACHE安裝

第一步:運(yùn)行apache_1.3.22-win32-x86.msi,一路點(diǎn)確定和接受就行,基本比較傻瓜,為了方便期間和符合我

的習(xí)慣我安裝的默認(rèn)路徑是 c:\ ,這樣就安裝在C盤下的APACHE的路徑下,同時(shí)默認(rèn)域?yàn)閞oot.dev。

第二步:(我在這里作了一個(gè)虛擬主機(jī),此步可以不做,根據(jù)你自己的需求)

編輯c:\apache\conf\httpd.conf

找到 #NameVirtualHost *

修改為 NameVirtualHost 192.168.0.16 #注意這個(gè)IP為你自己主機(jī)設(shè)的IP

找到 ServerName root.dev

修改為 #ServerName root.dev

添加

<VirtualHost 192.168.0.16>

ServerAdmin root@localhost

ServerName root.dev

DocumentRoot c:/apache/htdocs

ErrorLog c:/apache/logs/error_log

TransferLog c:/apache/logs/access_log

ScriptAlias /cgi-bin c:/apache/cgi-bin

</VirtualHost>

第三步:將文件名 c:\apache\htdocs\index.html.en 改為c:\apache\htdocs\index.html

第四步:重新啟動(dòng),訪問 http://root.dev 瀏覽正常,顯示APACHE歡迎頁(yè)



------------小小的成功!可以喝口水了!----------------------------





2。MYSQL安裝

第一步: 解壓 mysql-3.23.32-win.zip 到目錄 D:\MYSQL

第二步: 進(jìn)入D:\MYSQL 運(yùn)行SETUP.EXE 一路回車,默認(rèn)安裝到 C:\MYSQL



------------這一步應(yīng)該沒有什么問題!-------------------------------





3。PHP安裝

第一步: 解壓 php4.0.4pl1-win32.zip 到目錄 D:\PHP

第二步: 將D:\PHP下拷貝到C盤根目錄下

第三步: 進(jìn)入C:\PHP ,開始配置PHP

將文件名 php.ini-dist 改為 php.ini

同時(shí)拷貝 php.ini 和 php4ts.dll 到WIN2000的系統(tǒng)安裝目錄下

的 system32和system目錄下 (很重要,別忘了)

再次修改APACHE的配置文件httpd.conf (忘了吧!在c:\apache\conf\httpd.conf)

添加:

LoadModule php4_module c:/php/sapi/php4apache.dll

AddType application/x-httpd-php .php4

ScriptAlias /php4/ "C:/php/"

Action application/x-httpd-php4 "/php4/php.exe"

AddType application/x-httpd-php4 .php

第四步: 重新啟動(dòng)系統(tǒng)

第五步: 測(cè)試

編寫測(cè)試文件 info.php (拷貝到目錄 c:\apache\htdocs\ 下)

文件內(nèi)容:(就一行)

<? phpinfo(); ?>

訪問: http://localhost/info.php 或 http://root.dev/info.php

如果看到PHP的歡迎測(cè)試頁(yè)面,說明安裝成功!

到目前為止,你的系統(tǒng)已經(jīng)可以運(yùn)行PHP程序了!

你已經(jīng)配置好了 win2000+apache+php+mysql



----------------成功在望!吃些干糧,想5分鐘MM,上趟廁所,或者騷擾一下隔壁的大哥---------

---如果你能確定2件事就可以往下進(jìn)行了:

1.你的智商確實(shí)比中國(guó)足協(xié)的那堆廢物高

2.真的很想進(jìn)入JSP的世界遨游





4。JDK的安裝

第一步:直接運(yùn)行 j2sdk1_3_0-win.exe,一路回車安裝,我這里默認(rèn)的安裝路徑為d:\jdk1.3

第二步:配置環(huán)境變量

在我的電腦上點(diǎn)擊鼠標(biāo)右鍵-屬性-點(diǎn)選高級(jí)-點(diǎn)選環(huán)境變量

彈出環(huán)境變量對(duì)話框,新建以下變量名和值:

-------------------------------------

變量名:path

變量值:d:\jdk1.3\bin

變量名:JAVA_HOME

變量值:d:\jdk1.3

變量名:CLASSPATH

變量值:.\;d:\jdk1.3\lib\dt.jar;d:\jdk1.3\lib\tools.jar;

第三步:重新啟動(dòng)計(jì)算機(jī)使配置的環(huán)境變量生效



5。TOMCAT安裝

第一步:直接運(yùn)行安裝jakarta-tomcat-4.0.4.exe,我這里默認(rèn)的安裝路徑是c:\Apache Tomcat 4.0

這時(shí)如果單獨(dú)啟動(dòng)TOMCAT(到Tomca目錄下運(yùn)行startup.bat啟動(dòng)Tomcat或在菜單欄運(yùn)行start

tomcat),就已經(jīng)可以運(yùn)行JSP文件了,但是我們還沒有將APACHE和TOMCAT集成在一起,因?yàn)?br>
雖然TOMCAT有內(nèi)置的一個(gè)APACHE的HTTP服務(wù),但是他僅僅對(duì)JSP程序體現(xiàn)出比較好的執(zhí)行效率

和性能,對(duì)于靜態(tài)頁(yè)面的處理速度遠(yuǎn)不如APACHE,所以為了一個(gè)完美的WEB系統(tǒng),我們要將

APACHE和TOMCAT集成在一起!

(下面就是集成他們的具體配置步驟,請(qǐng)注意仔細(xì)認(rèn)真,我搞了1天才終于搞定。

第二步:先配置APACHE

打開c:\apache\conf\httpd.conf

添加以下語句:

#------------------------------------------

LoadModule jk_module libexec/mod_jk.dll

AddModule mod_jk.c

JkWorkersFile "c:\Apache Tomcat 4.0\conf\worker.properties"

JkLogFile logs/mod_jk.log

JkLogLevel info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkMount /*.jsp ajp13

JkMount /servlet/* ajp13

#-----------------------------------------------------

注意:以上語句的基本意思是:

第一、二句:指定APACHE和TOMCAT連接插件的位置和名稱

第三句:指出mod_jk工作所需要的工作文件的位置

第七、八句:是將所有和jsp和servlet的請(qǐng)求通過Apj13的協(xié)議送給Tomcat,讓Tomcat來處理

第三步:將下載的mod_jk.dllcopy到安裝Apache目錄下的libexec下就可以了

第四步:TOMCAT配置

首先是在c:\Apache Tomcat4.0\conf目錄下建一個(gè)worker.properties

文件內(nèi)容如下:

#----------------------------------------------------------

# $Header: /home/cvs/jakarta-tomcat/src/etc/Attic/workers.properties,v 1.3.2.2 2000/10/16 01:59:22 larryi Exp $

# $Revision: 1.3.2.2 $

# $Date: 2000/10/16 01:59:22 $

#

#

# workers.properties -

#

# This file provides jk derived plugins with with the needed information to

# connect to the different tomcat workers.

#

# As a general note, the characters $( and ) are used internally to define

# macros. Do not use them in your own configuration!!!

#

# Whenever you see a set of lines such as:

# x=value

# y=$(x)something

#

# the final value for y will be valuesomething

#

# Normaly all you will need to modify is the first properties, i.e.

# workers.tomcat_home, workers.java_home and ps. Most of the configuration

# is derived from these.

#

# When you are done updating workers.tomcat_home, workers.java_home and ps

# you should have 3 workers configured:

#

# - An ajp12 worker that connects to localhost:8007

# - An ajp13 worker that connects to localhost:8009

# - A jni inprocess worker.

# - A load balancer worker

#

# However by default the plugins will only use the ajp12 worker. To have

# the plugins use other workers you should modify the worker.list property.

#

#



#

# workers.tomcat_home should point to the location where you

# installed tomcat. This is where you have your conf, webapps and lib

# directories.

#

workers.tomcat_home=c:\Apache Tomcat 4.0





#

# workers.java_home should point to your Java installation. Normally

# you should have a bin and lib directories beneath it.

#

workers.java_home=d:\jdk1.3



#

# You should configure your environment slash... ps= on NT and / on UNIX

# and maybe something different elsewhere.

#

ps=\

# ps=/



#

#------ ADVANCED MODE ------------------------------------------------

#---------------------------------------------------------------------

#



#

#------ DEFAULT worket list ------------------------------------------

#---------------------------------------------------------------------

#

#

# The workers that your plugins should create and work with

#

worker.list=ajp12, ajp13



#

#------ DEFAULT ajp12 WORKER DEFINITION ------------------------------

#---------------------------------------------------------------------

#



#

# Defining a worker named ajp12 and of type ajp12

# Note that the name and the type do not have to match.

#

worker.ajp12.port=8007

worker.ajp12.host=localhost

worker.ajp12.type=ajp12

#

# Specifies the load balance factor when used with

# a load balancing worker.

# Note:

# ----> lbfactor must be > 0

# ----> Low lbfactor means less work done by the worker.

worker.ajp12.lbfactor=1



#

#------ DEFAULT ajp13 WORKER DEFINITION ------------------------------

#---------------------------------------------------------------------

#



#

# Defining a worker named ajp13 and of type ajp13

# Note that the name and the type do not have to match.

#

worker.ajp13.port=8009

worker.ajp13.host=localhost

worker.ajp13.type=ajp13

#

# Specifies the load balance factor when used with

# a load balancing worker.

# Note:

# ----> lbfactor must be > 0

# ----> Low lbfactor means less work done by the worker.

worker.ajp13.lbfactor=1



#

# Specify the size of the open connection cache.

#worker.ajp13.cachesize



#

#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------

#---------------------------------------------------------------------

#



#

# The loadbalancer (type lb) workers perform wighted round-robin

# load balancing with sticky sessions.

# Note:

# ----> If a worker dies, the load balancer will check its state

# once in a while. Until then all work is redirected to peer

# workers.

worker.loadbalancer.type=lb

worker.loadbalancer.balanced_workers=ajp12, ajp13





#

#------ DEFAULT JNI WORKER DEFINITION---------------------------------

#---------------------------------------------------------------------

#



#

# Defining a worker named inprocess and of type jni

# Note that the name and the type do not have to match.

#

worker.inprocess.type=jni



#

#------ CLASSPATH DEFINITION -----------------------------------------

#---------------------------------------------------------------------

#



#

# Additional class path components.

#

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)classes



#

# The XML parser provided with Tomcat

#

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)jaxp.jar

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)parser.jar



#

# Tomcat`s implementation

#

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)jasper.jar

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)servlet.jar

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)webserver.jar



#

# Javac as available from Java2SE

#

worker.inprocess.class_path=$(workers.java_home)$(ps)lib$(ps)tools.jar



#

# Setting the command line for tomcat

# Note: The cmd_line string may not contain spaces.

#

worker.inprocess.cmd_line=-config

worker.inprocess.cmd_line=$(workers.tomcat_home)/conf/jni_server.xml

worker.inprocess.cmd_line=-home

worker.inprocess.cmd_line=$(workers.tomcat_home)



#

# The JVM that we are about to use

#

# This is for Java2

#

worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll



#

# And this is for jdk1.1.X

#

#worker.inprocess.jvm_lib=$(workers.java_home)$(ps)bin$(ps)javai.dll

#



#

# Setting the place for the stdout and stderr of tomcat

#

worker.inprocess.stdout=$(workers.tomcat_home)$(ps)inprocess.stdout

worker.inprocess.stderr=$(workers.tomcat_home)$(ps)inprocess.stderr



#

# Setting the tomcat.home Java property

#

worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home)



#

# Java system properties

#

# worker.inprocess.sysprops=java.compiler=NONE

# worker.inprocess.sysprops=myprop=mypropvalue



#

# Additional path components.

#

# worker.inprocess.ld_path=d:$(ps)SQLLIB$(ps)bin

#



#--------------------------------------配置文件完畢-------------------------------------



在這個(gè)文件中需要注意的是要修改只有兩個(gè)地方,一個(gè)是workers.tomcat_home,

這是指定Tomcat工作的目錄,另外一個(gè)是workers.java_home,這是指定Jdk的目

錄,大家可以做適當(dāng)修改!我這里的配置沒有修改,都是符合我安裝系統(tǒng)的配置!



其次,配置TOMCAT核心文件,打開 c:\Apache Tomcat4.0\conf\server.xml

修改如下:

將<!-- Define an AJP 1.3 Connector on port 8009 -->

<!--

<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"

port="8009" minProcessors="5" maxProcessors="75"

acceptCount="10" debug="0"/>

-->

的<!-- --> 去掉,這句話熟悉XML的人都知道它是注釋,因?yàn)槟J(rèn)的Tomcat4

是沒有啟用Apj13的8009的端口即mod_jk所使用,修改后如下:

<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"

port="8009" minProcessors="5" maxProcessors="75"

acceptCount="10" debug="0"/>

然后保存,現(xiàn)在你的Tomcat和Apache的配置基本完成了。



第五步:所有配置基本完成,重新啟動(dòng)計(jì)算機(jī),開始整體測(cè)試!





測(cè)試:大家首先啟動(dòng)Apache,然后在瀏覽器里輸入http://localhost,如果能看

到Apache的歡迎頁(yè)面,那么恭喜您,第一步成功了。然后回到Tomca目錄下

運(yùn)行startup.bat啟動(dòng)Tomcat,再打開瀏覽器輸入:http://localhost:8080/

如果看到可愛的Tomcat,那么恭喜您,Tomcat也沒有問題,最后最重要的是

Apache下可以解釋jsp和Servlet,把下面的代碼copy到文本編輯器中命名為

hello.jsp,

內(nèi)容如下:

<%@ page contentType="text/html;charset=gb2312"%>

<html>

<body>

<%String str="Hello World!";%>

<%str=str+"你好";%>

<%=str%>

</body>

</html>

將它保存到C:\Apache Tomcat 4.0\webapps\ROOT下,然后在瀏覽器里輸入

http://localhost/hello.jsp如果看到了Hello,那么您的確成功了。

------------------至此你已經(jīng)大功告成,可以哼一個(gè)小曲了--------------------------

我的這個(gè)配置文檔是經(jīng)過考驗(yàn),確實(shí)可以正常通過并運(yùn)行的,希望能給你有所幫助,如果在進(jìn)

行過程中有任何問題,請(qǐng)通知我!

我的QQ:5359496

EMAIL:apollo@risesun-cn.com

其次我再闡述兩個(gè)問題:

1。由于我在配置APACHE中使用了虛擬主機(jī),所以訪問地址可以是:

http://localhost和http://root.dev,但是如果想http://root.dev訪問成功的話,請(qǐng)?jiān)?br>
瀏覽器里做如下設(shè)置:

INTERNET選項(xiàng)-連接-局域網(wǎng)設(shè)置

選擇 “使用代理服務(wù)器”,地址:192.168.0.16 (寫你主機(jī)的IP) 端口:80



2。對(duì)于APACHE主機(jī)下訪問的JSP文件,實(shí)際上物理上不存在與APACHE的主機(jī)上,而是存在在

TOMCAT的主機(jī)目錄里,例如:

http://localhost/hello.jsp 中hello.jsp文件實(shí)際不在 c:\apache\htdocs\下,而在

C:\Apache Tomcat 4.0\webapps\ROOT 下。這點(diǎn)請(qǐng)注意,不要混淆概念!
!!!!!!!!另外一定要下載與本文相同的版本,否則很容易出錯(cuò).切記勿忘!!!!!