JSP动态网站安装环境全过程
Win2K+Apache+Tomcat+JDK+MySQL+JSP+PHP+Dreamweaver 一、下载软件:(1)Apache:apache_1.3.22-win32-x86.exe http://nagoya.apache.org/mirror/httpd/binaries/win32/old/ (http://nagoya.apache.org/mirror/httpd/binaries/win32/ 选择OS及Apache版本。)(2)
Apache 支持Tomcat的插件 Mod_jk:mod_jk.dllhttp://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3/bin/win32/i386/ (http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3/bin/ 选择OS及版本。)(3)
JDK:j2sdk-1_4_1_02-windows-i586.exehttp://java.sun.com/webapps/download/DisplayLinks/(http://java.sun.com/j2se/1.4.1/download.html 选择安装OS平台。)(4)
MySQL:myodbc-2.50.39-nt.zip
(mysql-max-3.23.56-win.zip)http://www.mysql.com/downloads/mysql-3.23.html (http://www.mysql.com/downloads/index.html 选择安装OS平台及MySQL版本。)(5)
MySQL ODBC:MyODBC-3.51.06.exehttp://www.mysql.com/downloads/api-myodbc-3.51.html(http://www.mysql.com/downloads/index.html 选择OS平台及MySQL-ODBC版本。)(6)
MySQL JDBC:mysql-connector-java-2.0.14.ziphttp://www.mysql.com/downloads/api-myodbc-3.51.html(http://www.mysql.com/downloads/index.html 选择OS平台及MySQL-ODBC版本。)(7)
Tomcat:jakarta-tomcat-4.1.18.exehttp://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.24/bin/(http://jakarta.apache.org/site/binindex.cgi 选择OS平台及tomcat版本。)(8)
DreamWeaver mx:jetdown-DreamweaverMX.rarhttp://soft.jetdown.com/soft/38.htm (9)
PHP:php-4.3.2RC3-Win32.zip
http://qa.php.net/ 选择OS平台。(http://www.php.net/downloads.php 选择OS平台及PHP版本。) 二、安装步骤:(1)
停止IIS等Web服务器,退出各种防火墙。(2)
安装JDK:j2sdk-1_4_1_02-windows-i586.exe直接双击“j2sdk-1_4_1_02-windows-i586.exe”安装到C:\j2sdk1.4.1_02即可。在我的电脑上点击鼠标右键-属性-高级-环境变量:path:C:\j2sdk1.4.2\binJAVA_HOME:C:\j2sdk1.4.1_02CLASSPATH:.\; C:\j2sdk1.4.2\lib \dt.jar; C:\j2sdk1.4.2\lib \tools.jar;(3)
安装MySQL:mysql-max-3.23.53-win.zip;展开“mysql-max-3.23.53-win.zip”,直接双击setup.exe安装到C:\mysql即可。Mysql自动将WinMySqlAdmin启动放在“开始”——“程序”——“启动”,开机会自动启动MySql。如果手动启动MySql:Ø
cd c:\mysql\binØ
mysqld.exeØ
winmysqladmin.exe
(输入注册用户名/口令例如:root/root)Ø
mysql 数据库名
(进入到MySql环境,同时打开某一个数据库)Ø
mysql –u 用户名 –p口令 数据库名 (使用用户名口令打开某一个数据库,-u 和用户名之间有一空格,-p 和口令之间无空格)Ø
use 数据库名
(在MySql中,打开另一个数据库)Ø
show tables;
(显示当前数据库中的所有表名)Ø
desc 表名;
(显示该表的结构)Ø
exit
(退出MySql) (4)
安装MySql ODBC:myodbc-2.50.39-nt.zip
(MyODBC-3.51.06.exe;)展开myodbc-2.50.39-nt.zip,运行setup.exe进行安装;安装MyODBC-3.51.06.exe时,直接双击即可。打开控制面板-管理工具-ODBC,选择“用户DSN”,按“添加”按钮,选择该ODBC驱动程序,增加一个数据源例如mysql,然后打开DreamWeaver mx,输入连接名称、URL、用户名和密码,按“测试”按钮,进行测试。如下图所示: (5)
安装JDBC:mysql-connector-java-2.0.14.zip展开mysql-connector-java-2.0.14.zip,将文件夹mysql-connector-java-2.0.14中mysql-connector-java-2.0.14-bin.jar文件复制到C:\Apache Group\Tomcat 4.1\webapps\examples\WEB-INF\lib(...\WEB-INF\lib需要建立,examples是tomcat自带的测试站点的位置),然后打开DreamWeaver mx,输入连接名称、URL、用户名和密码,按“测试”按钮,进行测试。如下图所示:http://photo.hexun.com/p/2005/1220/7408/b_33DDF16236BB8671.jpg
如果建立自己的站点同样需要将mysql-connector-java-2.0.14-bin.jar文件复制到你的站点根下WEB-INF\lib (...\WEB-INF\lib需要建立)。http://photo.hexun.com/p/2005/1220/7408/b_FC0572C50D30858C.jpg
http://photo.hexun.com/p/2005/1220/7408/b_D781A9DE19D96338.jpg
(6)
安装Tomcat:jakarta-tomcat-4.1.18.exe直接双击jakarta-tomcat-4.1.18.exe即可。在浏览器中键入:http://localhost:8080/
(察看是否安装成功)该主页的位置:C:\Apache Group\Tomcat 4.1\webapps\ROOT\index.jsp点击:Tomcat Administration,输入管理员账号:admin/空,进入管理界面。 (7)
安装Dreamweaver mx:jetdown-DreamweaverMX.rar展开jetdown-DreamweaverMX.rar,点击setup.exe安装即可。启动Dreamweaver mx,鼠标点击工具栏中的“在浏览器中预览/调试”按钮,选择“编辑浏览器列表”,选中“在浏览器中预览”,取消选择“使用临时文件预览”,以防止在浏览中,浏览地址部分或浏览内容出现乱码问题。(8)
安装Apache:apache_1.3.22-win32-x86.exe直接双击apache_1.3.22-win32-x86.exe进行安装,输入域名例如lyunc.com/www.lyunc.com。安装完成后,更改主页文件名:将文件名 c:\Apache Group\apache\htdocs\index.html.en 改为c:\Apache Group\apache\htdocs\index.htmlApache的主页:C:\Apache Group\Apache\htdocs\index.html 启动浏览器进行测试,http://localhost ,如果显示Apache欢迎页面即告成功。注:单独安装和启动TOMCAT,就已经可以运行JSP文件了,但是我们还没有将APACHE和TOMCAT集成在一起,因为虽然TOMCAT有内置的一个APACHE的HTTP服务,但是他仅仅对JSP程序体现出比较好的执行效率和性能,对于静态页面的处理速度远不如APACHE,所以为了一个完美的WEB系统,我们要将APACHE和TOMCAT集成在一起!
(9)
安装Apache 支持Tomcat的插件 Mod_jk:mod_jk.dll将mod_jk.dll拷贝到c:\Apache Group\apache\libexec\(10)
集成Apache和Tomcat1.
配置ApacheØ
打开 c:\Apache Group\apache\conf\httpd.confØ
在该文件的末尾添加如下几句:#----在apache中配置tomcat------------------------------- LoadModule jk_module libexec/mod_jk.dll AddModule mod_jk.c JkWorkersFile "c:\Apache Group\Tomcat 4.1\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的请求通过Apj13的协议送给Tomcat,让Tomcat来处理。2.
(9)必须完成:安装Apache 支持Tomcat的插件 Mod_jk3.
配置TomcatØ
在C:\Apache Group\Tomcat 4.1\conf目录下建一个文件:worker.propertiesØ
在该文件中添加如下内容:#---------------------------------------------------------- # $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. # 需要指定安装Tomcat的目录 workers.tomcat_home=c:\Apache Group\Tomcat 4.1 # # workers.java_home should point to your Java installation. Normally # you should have a bin and lib directories beneath it. # # 需要指定安装JDK的目录 workers.java_home=C:\j2sdk1.4.1_02 # # 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 # #--------------------------------------配置文件完毕------------------------------------- Ø
在该文件中需要修改两处内容:一处是workers.tomcat_home,这是指定Tomcat工作的目录;另外一处是workers.java_home,这是指定Jdk的目录。 Ø
配置TOMCAT核心配置文件server.xml:由于安装的Tomcat4.1可以省略这一步;如果安装的是Tomcat4.0则需要下面的过程:打开 c:\Apache Group\Apache Tomcat4.1\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" -->; 的<!-- -->; 注释去掉,因为默认的Tomcat4.0是没有启用Apj13的8009的端口即mod_jk所使用,修改后如下: Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75" acceptCount="10" debug="0";
然后保存,现在你的Tomcat和Apache的配置基本完成了。 (11)
安装环境整体测试l
重启计算机,启动Apache和Tomcat。l
测试Apache:在浏览器中输入http://localhost,显示Apache欢迎界面。l
测试Tomcat:在浏览器中输入http://localhost:8080/,显示Tomcat界面。l
测试Apache下可以解释JSP和Setvlet:Ø
建立一个JSP文档:Hello.jspØ
在该文档中添加如下内容:<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>测试Apache+Tomcat</title></head> <body>祝贺您:成功地完成了Apache和Tomcat的集成 !</body></html>Ø
将Hello.jsp该文件保存到C:\Apache Group\Tomcat 4.1\webapps\ROOT文件夹下。Ø
在浏览器中输入http://localhost/hello.jsp,显示“祝贺。。。”信息。(12)
关于.JSP实际存放位置的说明:对于APACHE主机下访问的JSP文件,实际物理上没有存在APACHE的目录下,而是放在TOMCAT的目录里,例如:http://localhost/hello.jsp 中hello.jsp文件实际不在c:\Apache Group\apache\htdocs\下,而在c:\Apache Group\Tomcat 4.1\webapps\ROOT 下。请注意,不要混淆概念!(13)
MySql 更改数据库管理员ROOT账号的密码:C:\mysql\bin\mysqladmin –u root –p password 新密码回车后需要输入root账号的原密码,缺省密码为空,直接回车即可。建立新账号:mysql>use mysql
mysql>grant all privilege on *.* to 新账号名@localhost
identified by ‘some_pass’ with grant option;
mysql>update set password=’新密码’ where user=’用户名’;(14)
Apache修改主页的位置以及主页缺省的名字:c:\Apache Group\Apache\conf\httpd.confØ
ServerName xxx.xxx.xxx.xxxØ
DocumentRoot "C:/csnews/"Ø
<Directory "C:/csnews/">Ø
在文件尾加入:DirectoryIndex index.htm index.html index.php index.jspØ
重启系统Ø
在定义网站根的位置放置一个index.html测试主页:其内容为
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>我的测试主页Index.html</title>
</head>
<body>
祝贺您:测试主页成功 !
</body>
</html> Ø
在浏览器中键入http://localhost进行测试,如果该主页显示则设置成功。(15)
Tomcat修改主页的位置以及主页缺省的名字:c:\Apache Group\Tomcat 4.1\conf\server.xmlØ
建立虚拟主机,启动浏览器,http://localhost:8080Ø
点击Tomcat Administration,输入管理员账号:admin/口令Ø
点击Service,在右上方下拉框中选择:Create New Host,创建一个虚拟主机。Ø
键入:Name:csnews (虚拟站点名称)Ø
键入:Application Name:csnews (应用名称)Ø
点击“Save”和“Commit Changes”,进行保存和提交保存。Ø
点击新建虚拟节点(csnews),在右上方下拉框中选择:Create New Context,创建虚拟主机的根。Ø
键入Document Base:c:\csnews,虚拟主机网站主页存放的位置。Ø
更改Use Naming:false为true。Ø
点击“Save”和“Commit Changes”,进行保存和提交保存。Ø
再点击Service,更改Default Hostname:localhost为新建虚拟主机名称(csnews)。Ø
点击“Save”和“Commit Changes”,进行保存和提交保存。Ø
更改Tomcat配置文件:c:\Apache group\Tomcat 4.1\conf\server.xml,设置“defaulthost”为新建虚拟主机名称(csnews)(在Tomcat管理界面中,如果更改Service中的Default Hostname成功,则可以省略此步),将新建虚拟主机(csnews)的“path”设置为空。Ø
重启Tomcat,最好在“服务”面板中关闭和启动Tomcat,否则在“程序”——“Apache Tomcat 4.1”——“Stop tomcat”/“Start tomcat”有问题。Ø
启动IE,键入:http://127.0.0.1:8080,则启动虚拟主机的主页index.jsp。特别注意:http://localhost:8080,还是启动原Tomcat的缺省主页:C:\Apache Group\Tomcat 4.1\webapps\ROOT\index.jspØ
注意:“程序”——“Apache Tomcat 4.1”——“Tomcat Administration”失效,使用IE:http://localhost:8080/admin,调用之。(16)
Tomcat修改主页的缺省端口号:将8080端口改为80端口。Ø
启动浏览器,http://localhost:8080/adminØ
点击Tomcat Administration,输入管理员账号:admin/口令Ø
点击Service,在右上方下拉框中选择:Create New Connector。输入“IP Address”为本主机的IP地址(xxx.xxx.xxx.xxx)。输入“Port Number”为80。Ø
重启Tomcat,最好在“服务”面板中关闭和启动Tomcat,否则在“程序”——“Apache Tomcat 4.1”——“Stop tomcat”/“Start tomcat”有问题。Ø
IE测试:http://127.0.0.1 (17)
建立Dreamweaver MX站点:Ø
启动Dreamweaver MXØ
在站点选项卡——下拉框中选择“编辑站点”,弹出“编辑站点”对话框。Ø
选择“新建”按钮,弹出新建站点向导。Ø
输入新建站点的名称:csnewsØ
选择“是,我想使用服务器技术”,从下拉框中选择“JSP”,单击“下一步”。Ø
选择“在本地编辑和测试”,在文本框中输入站点位置:c:\csnews,单击“下一步”。Ø
输入浏览站点的根目录:http://127.0.0.1/ ,“测试”一下看是否成功,单击“下一步”。Ø
选择“否”:测试完毕不拷贝到另外的计算机。Ø
点击“完成”,站点内容被装入到Dreamweaver中,结束建立站点过程。(18)
建立Dreamweaver MX测试服务器:Ø
本地测试服务器:将文件mysql-connector-java-2.0.14-bin.jar从C:\Apache Group\Tomcat 4.1\webapps\examples\WEB-INF\lib复制到
C:\Program Files\Macromedia\Dreamweaver MX\Configuration\JDBCDrivers中,并将jar包展到该目录下,供本地测试站点使用。Ø
在右边的选项卡中,选择“应用服务器”——“测试服务器”,与建立站点完全一样。Ø
建立Dreamweaver MX数据库连接JDBC: http://photo.hexun.com/p/2005/1220/7408/b_B1D379C28218DE4A.jpg
Ø
建立Dreamweaver MX测试服务器:http://photo.hexun.com/p/2005/1220/7408/b_E6AD380BB4A57230.jpg
http://photo.hexun.com/p/2005/1220/7407/b_3F5167AB924D8996.jpg
http://photo.hexun.com/p/2005/1220/7407/b_52C97B36E32C7E3C.jpg
(19)
安装PHP:php-4.3.2RC3-Win32.zipØ
解压php-4.3.2RC3-Win32.zip到一个临时文件夹中,例如:c:\tempØ
建立PHP安装文件夹,例如c:\PHP4.3.2Ø
将c:\temp\ php-4.3.2RC3-Win32文件夹内容复制到c:\PHP4.3.2Ø
将c:\PHP4.3.2\php.ini-dist改为php.iniØ
将c:\PHP4.3.2\php.ini和c:\PHP4.3.2\php4ts.dll拷贝到Win2K系统安装目录中的system32和system文件下。Ø
再次修改Apache配置文件:C:\Apache Group\Apache\conf\httpd.conf
i.
#-------------在Apache中配置PHP----------------------- LoadModule php4_module C:/PHP4.3.2/sapi/php4apache.dll AddType application/x-httpd-php .php4 ScriptAlias /php4/ "C:/php4.3.2/" Action application/x-httpd-php4 "/php4/php.exe" AddType application/x-httpd-php4 .php 注意:如果你安装的PHP目录不是C:\PHP4.3.2,则只需要更改第2、3句的目录即可。
ii.
重启Apache服务器:控制面板
——管理工具——服务。
iii.
编写一个PHP测试程序:testphp.php<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><body><? phpinfo(); ?>
//显示PHP配置信息测试PHP 4.3.2成功,祝贺您!</body></html>
iv.
测试PHP:IE:http://127.0.0.1/testphp.php,如果出现祝贺信息,你就安装PHP成功了。注意testphp.php大小写敏感。(20)
关于“本地节点”的几点说明:l
http://127.0.0.1 、http://本地节点名 和http://本机IP地址 功能同效。l
上面的描述与http://localhost 不同效,localhost已经被Tomcat所占用,http://localhost仅显示Tomcat页面,但其中功能失效,如果要使用Tomcat页面的管理功能等,则需要使用:http://localhost:8080 即可。
页:
[1]