步骤五:配置Apache
打开Apache2\conf\httpd.conf文件,查找到下面的内容:

# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#

ServerName 127.0.0.1:8080
如果你需要改服务器/IP,则修改上面蓝色代码

—————————————————————————————

再查找下面内容:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#

DocumentRoot "D:/apache2/htdocs"
如果你想改变放置运行JSP文件的目录,请将上面蓝色的内容修改成: DocumentRoot "盘符:/路径",注意,要使用"/"而不是"\"。

—————————————————————————————

再查找下面内容:
#Listen 12.34.56.78:80
Listen 8080
如果你想修改Apache的监听端口,请修改这里。
httpd.conf的配置就到这里完成了,如果你想进行更详细更深入的配置,请查看相关的文章。

打开MS-DOS方式,去到D:\apache2\bin\目录下,输入下面命令将Apache安装成服务(安装成功后就可以在任务栏的Monitor里看到):
apache -k install 回车

双击任务栏右下角的Apache Monitor,你会在左边看到一个"Apache2"(如下图),再按右边的Start按钮,启动Apache2!


打开IE,在地址栏上输入:http://127.0.0.1:8080/,成功的话,你会看到下面激动人心的画面:


至此,你已经成功安装了Apache,现在你只要把html文件放到apache2/htdocs/目录下,即可访问,例如该目录下有一个文件叫hello.htm,那么访问方式:http://127.0.0.1:8080/hello.htm

上一步   下一步