系统默认2000 server+iis,ip:192.168.0.1
1.安装sqlserver2000(记得设置混合身份认证方式,并为sa设置密码)
2.安装oracle9i(新手请参考网上关于oracle的安装)
3.安装mysql到c:/mysql
本人安装了mysql-3.23.56-win.zip和MyODBC-3.51.06.exe,只需傻瓜式安装即可,安装后别忘了为root设置密码!
4.安装apache,用来调试php
为免和apache冲突,先把iis端口改成81(或者先停掉iis),安装apache2.0.43 for win32
然后修改httpd.conf
1)DocumentRoot 改为自己网站的目录
2)添加对php的支持
在httpd.conf最后加以下语句
#PHP Configure##BEGIN##
scriptAlias /php/ "c:/php4/"
Addtype application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
#PHP Configure##END##
3)查找Alias,在后面加
Alias /cxl34 "d:/web/apache"
<Directory "d:/web/apache">
Options Indexes FollowSymLinks MultiViews IncludesNoExec
AddOutputFilter Includes html
AllowOverride None
Order allow,deny
Allow from all
</Directory>
来建立虚拟目录
4)修改DirectoryIndex index.php
DirectoryIndex index.html
DirectoryIndex index.htm
DirectoryIndex default.php
DirectoryIndex default.htm
5)查找 AddDefaultCharset ISO-8859-1 改成 #AddDefaultCharset ISO-8859-1
AddDefaultCharset GB2312 就可以默认支持中文编码了!
6)在网站目录下建立简单的html网页测试!
5.安装php-4.3.1-Win32.zip
1)解压缩到c:/php4,复制所有的dll到system32下
2)复制php.ini和php.exe到c:/winnt下
3)修改php.ini:
extension_dir=c:/php4/extensions/
include_path = "c:/php4/includes"
register_globals = on
extension=php_exif.dll
extension =php_zlib.dll
extension=php_gd.dll
extension =php_calendar.dll
extension=php_imap.dll
extension=php_ldap.dll
extension=php_mssql.dll
如无以上dll可不设置
4)在apache的目录下,建立index.php用phpinfo();测试!!!
6.先后安装jdk1.43和tomcat4.1
1)假设jdk安装在d:/webs/jdk,再安装tomcat到d:/Tomcat 4.1,tomcat最好设置成windows的启动服务!
2)右击“我的电脑”,选择“属性”->"高级“->“环境变量“->“系统变量“,添加classpath,值为d:/webs/jdk/lib/tools.jar;d:/webs/jdk/lib/dt.jar;D:/webs/Tomcat 4.1/common/lib,再添加path,值为d:/webs/jdk;d:/webs/jdk/bin,确定!
3)修改tomcat4.1/conf下的server.xml文件,在"</Host>"之前,"</Context>"之后添加 <Context path="/test" docBase="d:/test" debug="0" reloadable="true" crossContext="true"/>并保存,就建立了你自己的虚拟目录!重新启动修改生效!
4)在d:/test下建立index.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%
int i;
for(i=1;i<=10;i++)
{
out.println("<font size="+i+">"+i+"</font><br>");
}
%>
<p>在这里测试一下中文显示!<p>
在浏览器里打入http://192.168.0.1:8080/test就会看到index.jsp了!
到此为止,所需的软件已经安装完成,接下来就是调试三种语言以及访问数据库的情况!
先分别建立aspweb,phpweb,jspweb三个目录,然后设置iis,apache和tomcat分别指向这三个目录,然后在mysql,sql2000,oracle中分别建立aspweb,phpweb,jspweb三个数据库,并建立若干表,至于如何操作这三个数据库,就请自行查阅相关资料啦!
1.调试iis+asp
关于iis的设置比较简单,这里不再累赘,在目录下建立index.asp,然后用192.168.0.1:81测试(需要asp知识);
2.用asp访问sql2000
在sql2000里建立一个aspweb的数据库和user1表
建立公用数据库文件conn.asp
<%
strSQLServerName = "localhost"
strSQLDBUserName = "sa"
strSQLDBPassword = "******"
strSQLDBName ="aspweb"
Set conn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
conn.Open strCon
function CloseDatabase
Conn.close
Set conn = Nothing
End function%>
在调试的页中
<!--#include file="conn.asp"-->
<%set rs=server.createobject("adodb.recordset")
rs.open "user1",conn,1,3
....
%>
3.asp访问mysql(没有必要,测试用)
先登陆mysql,建立aspweb数据库和user1表
<%strconnection="DefaultDir=;Driver={myodbc driver};database=aspweb"
Set adoDataConn = Server.CreateObject("ADODB.Connection")
adoDataConn.Open strConnection
strQuery = "SELECT * FROM user1"
Set rs = adoDataConn.Execute(strQuery)
If Not rs.BOF Then
....
rs.Close
adoDataConn.Close
Set adoDataConn = Nothing
Set rsEmailData = Nothing
%>
4.asp访问oracle{}
5.调试apache+php
上文已经讲过,在apache的目录下,建立index.php,用phpinfo();测试(需要php知识),192.168.0.1!
6.php访问mysql
在php中建立phpweb数据库和user1表
<?
$hostname = "localhost";
$dbuser = "root";
$dbpasswd = "*****";
$id = mysql_connect($hostname,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
$query="SELECT * FROM user1";
$result=mysql_db_query("phpweb",$query,$id);
echo($result);
?>
6.php访问sql2000
在sql2000中建立phpweb数据库和user1表
<?
$hostname = "localhost";
$dbuser = "sa";
$dbpasswd = "*******";
$id = mssql_connect($hostname,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
$db = mssql_select_db("phpweb",$id) or die("无法连接数据库!");
$query = "select * from user1";
$result = mssql_query($query) or die("无法执行SQL:$query");
......
?>
7.php访问oracle{}
8.调试jsp+tomcat
上文已经提过
9.jsp访问sql2000
10.jsp访问mysql
11.jsp访问oracle
12.补遗:
1)asp和jsp结合Access数据库对一些小的应用也比较出色,但两者与Access的连接比较简单,安装Access更简单,请自行上网查阅有关资料!
2)php也可以在iis下配置并调试,但熟悉apache对hack活动有很大帮助,所以介绍用apache调试php。
3)可在phpweb目录下安装phpadmin,对mysql数据库的操作会简单一点;
4)在iis下配置cgi现在已经越来越少了,所以就不再介绍!
13.最后总结:以上重点介绍了三种环境的配置和三种语言对三种数据库的访问,但实际应用中asp/jsp+access(适合小型应用),asp+sql2000,php+mysql,jsp+oracle这几种组合最常用。
14.最后介绍一下asp.net环境的配置!
1)asp.net只能在xp pro,2000 server,server.net上运行,在这里只介绍2000 server下的调试。
1)确保安装了iis;
2)安装MS.Net.Framework_SDK,可以在微软的官方网站或visual studio.net的光盘里找到!这个软件很大,有130M左右,安装的时候也比较慢!
3)安装MDAC,同样可以在微软的官方网站下载!重新启动后,在iis的目录下写一个index.aspx文件
<%@ Page Trace="True" %>
<html>
<head>
<title>使用跟踪</title>
</head>
<script language="c#" runat="server">
void Page_Load(Object Sender, EventArgs E) {
Trace.Write("跟踪", "在页面载入时");
}
void SubmitBtn_Click(Object Sender, EventArgs E) {
Trace.Write("按钮", "按钮按下");
Trace.Write("账号", "账号是:" + Name.Text);
Trace.Write("密码", "密码是:" + Password.Text);
YouEntered.Text = "你好!" + Name.Text + "。您的密码是 " + Password.Text;
}
</script>
<form runat="server">
<table border="0">
<tr>
<td>账号</td>
<td><asp:TextBox id="Name" runat="server" /></td>
</tr>
<tr>
<td>密码</td>
<td><asp:TextBox id="Password" TextMode="Password"
runat="server" /></td>
</tr>
<tr>
<td></td>
<td><asp:Button id="SubmitDetailsBtn" text="提交"
onclick="SubmitBtn_Click" runat="server" /></td>
</tr>
</table>
<p><asp:Label id="YouEntered" runat="server" /></p>
</form>
</body>
</html>
用http://192.168.0.1:81/index.aspx测试一下!
在下一篇文章中,将讲述如何在单机上调试ftp,mail,real server,bqq,media server