Windows下打造完美的服务器平台_Web服务器教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!
Windows下打造完美的服务器平台(APACHE+JSP+CGI+PHP+ASP+MYSQL)
需要下载几个软件包:
1. php-5.0.2-Win32
2. apache_2.0.52-win32-x86-no_ssl
3. mysql-5.0.1-alpha-snapshot-win
4.iASP2.1.01
5.jakarta-tomcat-4.1.31
7.j2sdk-1_4_2-windows-i586
8.phpMyAdmin-2.6.0-pl2
9.ActivePerl-5.8.4.810-MSWin32-x86
一、下载软件包:
  1. PHP5 RC3
  PHP 的下载地址为: http://www.php.net/downloads.php,找到如下图位置,下载方框中的两个软件包。其中 PHP 5.0.0RC3 zip package 就是 PHP5 软件包,而 Collection of PECL modules for PHP 5.0.0RC3 则是 PHP5 的 PECL 扩展模块集合包。


2. Apache 2.0.52
  Apache 官方下载地址为: http://httpd.apache.org/download.cgi ,找到如下图位置,下载 For Windows 的 MSI 安装包,点击以后选择一个镜像进行下载。

3. MySQL 5.0.1
  MySQL 官方下载地址为:sql.com/downloads/mysql/5.0.1-snapshot.html" target=http://dev.mysql.com/downloads/mysql/5.0.1-snapshot.html,找到 Windows downloads 部分,下载 Without installer 包并保存于本地硬盘 ,如下图所示:

4.jakarta-tomcat-4.1.31
jakarta-tomcat-5.5.3是最新的版本,由于5.5.3版本需要jdk5.0的支持,我下载不到该版本,所以使用的是4.1.31,同样JDK也是使用j2sdk-1_4_2-windows-i586,当然如果你有5.0的版本,安装方法是一样的。该版本的下载地址:http://jakarta.apache.org/site/binindex.cgi 找到相应的版本下载即可,如图:

5.iASP2.1.01
一个让APACHE支持ASP的程序,下载地址是http://www.stryon.com.cn/products.asp?s=1 找到,简单的申请就可以下载到了。

6.j2sdk-1_4_2-windows-i586
由于JSP页面需要javac来编译运行,因此必须安装JDK(单装JRE不行)。打开页面http://java.sun.com/j2se/1.4.2/download.html 下载j2sdk-1_4_2-windows-i586


7.phpMyAdmin-2.6.0-pl2
phpMyAdmin-2.6.0-pl2可以让你在WEB环境下管理MYSQL数据库,其下载地址是:http://sourceforge.net/projects/phpmyadmin/
找到下面的下载连接,选择一个较近的镜像下载即可。

8.ActivePerl-5.8.4.810-MSWin32-x86
安装ActivePerl可以让Apache支持CGI和PL的程序,下载地址:http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
找到如下的页面进行下载MSI包:

二,安装与配置
1,     安装apache_2.0.52-win32-x86-no_ssl,将其安装在D:\Apache2\文件夹下面,安装过程就不用说了,一路NEXT就可以,安装完了就可以在任务栏的地方看将这样的图标 ,表示已经启动成功。打开网页http://127.0.0.1,出现安装成功的页面。

接下来对 Apache 的配置文件进行配置,使其支持PHP,用记事本打开 D:\Apache2\conf\ (我这里是按照默认安装路径安装,后面的设置按照自己的安装路径做相应的改变) 目录下的 httpd.conf 文件,定位到下面这行:
DirectoryIndex index.html index.html.var
在其后面添加一个 PHP 默认页,通常是 index.php ,如下:
DirectoryIndex index.html index.html.var index.php
为了使 Apache 识别 PHP 的相关扩展名,搜索并定位到下面这个部分:
<Directory "D:/Apache2/cgi-bin">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>

在后面添加如下两行:
AddType application/x-httpd-php .php .phtml .php3 .php4
AddType application/x-httpd-php-source .phps
指定 php 模块,找到并定位到如下这行:
#LoadModule ssl_module modules/mod_ssl.so
在下面添加一行:

LoadModule php5_module D:\PHP\php5apache2.dll
  使它指向 PHP5 目录下的 php5apache2.dll 文件,路径一定要准确。
  为了指定 Apache 识别中文,我们指定 GB2312 为默认编码。应该找到并定位到下面这行

AddDefaultCharset ISO-8859-1
将其修改为:
AddDefaultCharset GB2312
另外,如果要禁止目录浏览,查找并定位到下面这几行:
#……
#一些注释
#……
Options Indexes FollowSymLinks
去掉几行注释下面进跟着的一行的 Indexes 即可,修改后:
#……
#一些注释
#……
Options FollowSymLinks

  OK,保存 httpd.conf 文件后重起 Apache 服务器。

2.安装PHP 5.0.2
将下载来的 PHP5 RC3(php-5.0.0RC3-Win32.zip) 解压缩到 D:\PHP\ 目录下。复制 D:\PHP\ 目录下的 php5ts.dll 文件到 C:\windows\(如果是 windows 2000 操作系统,则为 C:\WINNT\ 目录,下同,不再重复说明) 目录下。
  复制 D:\PHP\ 目录下的下列 dll 文件于 C:\windows\system32\ 目录下:
  fdftk.dll
  fribidi.dll
  gds32.dll
  libeay32.dll
  libintl-1.dll
  libmhash.dll
  libmysql.dll
  libmysqli.dll
  ntwdblib.dll
  ntwdblib.dll
  yaz.dll
  其中 libmysql.dll 为 MySQL 4.1 之前版本的扩展支持,libmysqli.dll 为 MySQL 4.1 之后版本的扩展支持。因为我上面下载的是 MySQL 4.0.20 ,所以其实复制 libmysql.dll 即可。
  复制 C:\PHP5\ 目录下的 php.ini-dist 文件到 C:\windows\ 目录下,并改名为 php.ini ,并用记事本打开编辑:
  定位到下面两行:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
  修改下面一行使它指向 D:\PHP\ext\ 目录,修改后如下:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "D:\PHP\ext\"

测试 PHP 是否配置成功:

  打开记事本,输入如下这行代码:
<?php phpinfo(); ?>
保存为 phpinfo.php 文件,存放于 Apache2\htdocs\ 目录下,好了,打开浏览器,在地址栏中输入: http://localhost/phpinfo.php 并回车,如果一切顺利的话你将看到下面这个页面,到此 PHP5 的配置大功告成:

3.安装mysql-5.0.1-alpha-snapshot-win
很简单,不多说了。我们假设把它安装在D:\mysql目录下,打开该目录下的bin文件夹,运行winmysqladmin.exe配置mysql

输入管理员的用户名和密码就可以了。
以后每次启动,都可以在服务里面看到MYSQL进程已经打开。

4,安装phpMyAdmin-2.6.0-pl2
phpadmin不需要安装,直接COPY到网页目录下即可,将其命名为phpadmin。打开C:\Windows/php.ini文件, 查找 extension=php_mysql.dll 字串.删除掉前面的 ; 号extension=php_mysql.dll,启动 PHP 对 MYSQL 模块支持.
打开phpmyadmin文件夹下面的config.inc.php3文件,定位到下面的内容:
$cfg['Servers'][$i]['host']       = 'localhost'; // MySQL hostname or IP address
$cfg['Servers'][$i]['auth_type']   = 'config';   // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user']       = 'root';     // MySQL user
$cfg['Servers'][$i]['password']     = '';       // MySQL password (only needed
                                  // with 'config' auth_type)
将host,user和password修改成你自己的IP地址,用户和密码,打开网页http://127.0.0.1/phpmyadmin/index.php,如果可以看到下面的页面,恭喜你,安装成功了。

5,安装ActivePerl-5.8.4.810-MSWin32-x86
安装过程很简单,一路NEXT就可以了。我们将其安装在D:\usr下面,注意,ActivePerl-5.8.4.810-MSWin32-x86默认的根目录是Perl文件夹,按照国际上面的惯例,最好是usr作我根目录,以免在以后调试程序时候出现麻烦。
配置Apache让其支持CGI和PL文件。用记事本打开 D:\Apache2\conf\ (我这里是按照默认安装路径安装,后面的设置按照自己的安装路径做相应的改变) 目录下的 httpd.conf 文件,寻找
#ScriptAlias /cgi-bin/ "D:/Apache/cgi-bin/"
把前面的#号去掉 ,把D:/Apache/cgi-bin/新开为你需要支持CGI程序的目录,我设置的是f:/Web/cgi-bin。
寻找
<Directory "D:/Apache/cgi-bin">
同样,也修改为f:/Web/cgi-bin
寻找
AddHandler cgi-script .cgi
后面加上.pl ,即 AddHandler cgi-script .cgi .pl
OK,自己写个CGI程序测试一下:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";
保存为hello.cgi,放置在F:\WEB\CGI-BIN文件夹下面,使用浏览器打开http://127.0.0.1/cgi-bin/hello.cgi,出现如下的页面,安装成功。

6,安装j2sdk-1_4_2-windows-i586
由于安装tomcat前需要安装j2sdk,所以要先安装j2sdk-1_4_2-windows-i586,过程很简单,安装到D:\j2sdk文件夹。
设置环境变量,
JAVA_HOME = D:\j2sdk

在Path最后附加:
Path = ......;%JAVA_HOME%\bin

打开CMD,输入java –version,显示下面的内容
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
输入javac,显示:
C:\Documents and Settings\lin>javac
Usage: javac <options> <source files>
where possible options include:
-g                 Generate all debugging info
-g:none             Generate no debugging info
-g:{lines,vars,source}   Generate only some debugging info
-nowarn             Generate no warnings
-verbose             Output messages about what the compiler is doing
-deprecation         Output source locations where deprecated APIs are us
ed
-classpath <path>       Specify where to find user class files
-sourcepath <path>     Specify where to find input source files
-bootclasspath <path>   Override location of bootstrap class files
-extdirs <dirs>       Override location of installed extensions
-d <directory>         Specify where to place generated class files
-encoding <encoding>     Specify character encoding used by source files
-source <release>       Provide source compatibility with specified release
-target <release>       Generate class files for specific VM version
-help               Print a synopsis of standard options
表示JAVAC也安装成功。
7.安装jakarta-tomcat-4.1.31
jakarta-tomcat不需要安装,下载压缩包以后直接解压到D:\TOMCAT目录下,设置环境变量
TOMCAT_HOME =D:\TOMCAT
打开D:\tomcat\bin目录下的startup.bat启动tomcat,如果出现下图的状态,表示启动成功。如图:

使用MYIE打开 http://127.0.0.1:8080/index.jsp ,可以看到如下的页面,再次恭喜你,tomcat也安装成功。tomcat默认的HTTP端口和用户名可以去D:\tomcat\conf目录下修改server.xml和tomcat-user.xml文件。

整合Apache和Tomcat。用记事本打开 D:\Apache2\conf\ 目录下的 httpd.conf 文件,在最后面增加下面的内容:
LoadModule jk2_module modules/mod_jk2.so

在D:\Apache2\conf目录下新建一个workers2.properties文件,内容如下:
[shm]
info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.
file=anon

# Defines a load balancer named lb. Use even if you only have one machine.
[lb:lb]

# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1

# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
group=lb

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
group=lb

[status:]
info=Status worker, displays runtime information

[uri:/jkstatus/*]
info=The Tomcat /jkstatus handler
group=status:

如果懒得写代码,将该文件夹下面的workers2.properties.sample改成workers2.properties即可。
写一个JSP文件,内容如下:
<% out.println("Hello, world."); %>
保存放置在D:\tomcat\webapps\examples目录下,打开网页http://127.0.0.1/examples/index.jsp,就可以看到Hello, world.字样,这个效果和使用地址http://127.0.0.1:8080/examples/index.jsp看到的页面是一样的,说明Apache和Tomcat已经整合成功。
5,安装iASP2.1.01
安装过程iASP2.1.01会自动找到JDK的安装路径,所以安装过程很很是简单,我们将其安装在d:/Instant文件夹下面。

主要是后面的配置:
第一步:代理服务(proxy)选择:instant asp native servlet support
第二步:WEB SERVER选择:apache。(可以不管它提示)
第三步:选择apache的配置文件:httpd.conf的位置。我的为:D:\Program Files\Apache Group\Apache2\conf\\httpd.conf
版本选择2.X(根据您的apache版本选择)。
proxy:如果您有固定ip,添入您的固定ip。如果没有,那就添:127.0.0.1。
port: 这是apache与iasp之间的代理接口。使用默认(9098)即可。
server manager port:远程管理端口,选择默认(9095)即可。
第四步:配置完成。

配置完成以后,程序会自动在apache的配置文件httpd.conf最后加入了以下语句:


# iASP Setting
LoadModule iasp_module "d:/Instant/bin/apache/win32/2.0/iasp.dll"

Alias /iasp "d:/Instant"
IaspConfig server "d:/Instant/properties/server.properties"
IaspConfig rules "d:/Instant/properties/rules.properties"

通过更改httpd.conf更改apache的默认首页:

DirectoryIndex index.htm
DirectoryIndex index.php
DirectoryIndex index.asp

更改完毕后,保存,重启apache
执行:开始->程序->Instant ASP 2.1.01->Install iASP as NT Service
这样,iasp就被加到了win2000 server的服务中。

执行:开始->程序->Instant ASP 2.1.01->Start Instant ASP
这样,iasp就被立即打开。apache可以支持asp了!

从新启动Apache,发现如下:

这个主要是因为Iasp还不支持我们用的APACHE版本,问一个朋友要了一个支持apache_2.0.52的iasp.dll,替换d:/Instant/bin/apache/win32/2.0/iasp.dll,从新启动Apache成功,写一个ASP文件保存为index.asp.
<%
Response.Write "<BR><h1>Congradulations!<BR>Instant ASP has worked for you!</h1>"
%>
打开网页http://127.0.0.1/index.asp
出现:

这个iasp.dll不是很好,如果你希望在Apache安装ASP,建议使用Apache低一点的版本,使其有支持的iasp.dll文件.
三,组建自己的网站
1.安装vBulletin 3.0.3,去http://www.newvbb.com/下载NewvBB 团队中文化和功能修改后的NewvBB Core 1.1 Final (vBulletin 简体中文化插件版) 20040921。将得到的压缩包解压至F:\WEB\NEWVBB文件夹。打开http://127.0.0.1/phpmyadmin/index.php,新建一个mysql数据库newvbbcore,如图:

将 includes 目录下的 config.php.new 更名为 config.php,打开该文件夹,修改下面的内容为你自己的个人配置:
$servername = 'localhost';//你的IP地址
$dbusername = 'root';//mysql数据库用户名
$dbpassword = '';//mysql数据库密码
$dbname = 'newvbbcore';//刚刚建立的数据库
打开网页http://127.0.0.1/newvbb/install/install.php,进行安装。接下来就是简单的安装过程,直接点击下一步就可以完成NEWVBB的安装。安装完成以后根据提示删除如下文件:
install/install.php,就可以打开地址http://127.0.0.1/newvbb/index.php观看你的PHP论坛了。

2,     安装leobbs CGI论坛
去http://www.leobbs.com/下载最新提供的版本LeoBBSX040926,下载完成后解压,将CGI-BIN文件夹下面的全部文件放置在F:\WEB\CGI-BIN文件夹下面。non-cgi文件夹下面的全部文件放置在F:\WEB\NON-CGI文件夹下面。打开网页:http://127.0.0.1/cgi-bin/install.cgi,就可以看到安装页面,注意下面的安装路径:

点击设定完毕完成LEOBBS的安装,打开网页http://127.0.0.1/cgi-bin/leobbs.cgi可以看见我们的CGI论坛:

3,     安装JSP探针
由于JSP用得不是很,我也很少去关注这方面的代码,所以我们去http://xuyizhi.y365.com 下载怀才不遇 改写的JSP探针-V0.05测试结果,将其放置在D:\tomcat\webapps\examples下面,取名为jspchexk.jsp。打开网页http://127.0.0.1/examples/jspcheck.jsp,得到如下的页面:

至此,我们已经完成了JSP的全部安装工作。

来源:网络搜集//所属分类:Web服务器教程/更新时间:2013-04-14
相关Web服务器教程