Apache 学习(一 初见Apache)
1.Apache 和 tomcat 的纠缠
-
-
- Apache 的和Tomcat的比较这里不细说,Apache 是web服务器,着重于对静态的资源的获取,提升对静态资源的访问性能。tomcat 是应用服务器,准确的来说是为java 服务的,将jsp文件编译成servlet,相应客户的请求。
- 为什么经常将Apache 和 tomcat 放在一起,是应为Tomcat 也是属于Apache 基金组织的项目,tomcat 可以脱离于的Apache 单独的运行,是Apache 的增强。也可以将两者整合,整合的目的就是,提升系统的性能。
-
2.Apache 的hello world
怎样只启动Apache 服务,访问hello world 页面?
-
-
- 首先当然是下载Apache 的包了,下载之后放到磁盘中
-
- bin 启动脚本和管理器的存放位置
- conf 配置文件的位置
- htdocs 静态资源的存放位置,也可以通过配置文件,修改静态资源(项目)的位置
- logs log日志
- modules 模块的存放位置
D:\mytools\Apache24\conf\httpd.conf 这个文件是核心配置文件,仔细阅读英文,即使是百度翻译,里面精简的指导,能帮你少走很多弯路
-
- 打开这个文件在开头我们会看到官方提供的参考API 关于所有模块配置的说明:http://httpd.apache.org/docs/2.4/mod/directives.html
-
NOTE: Where filenames are specified, you must use forward slashes instead of backslashes (e.g., "c:/apache" instead of "c:\apache"). 这句话告诉要使用左斜杠,不要使用右斜杠,在windows 中要尤其注意
- Do not add a slash at the end of the directory path. 不要在文件的末尾加上斜杠
- 重点开始了:ServerRoot "D:/mytools/Apache24" Apache 的路径:第一是左斜杠 ,第二末尾不能加/ 这两点要注意
- Listen 80 监听端口:默认是80
- ServerAdmin aaa@qq.com 当apache 发生错误的时候会给你发送邮件
- DocumentRoot "D:/mytools/Apache24/htdocs" web项目存放路径
-
ErrorDocument 500 "The server made a boo boo."
ErrorDocument 404 /missing.html
ErrorDocument 404 "/cgi-bin/missing_handler.pl"
ErrorDocument 402 http://www.example.com/subscription_info.html 错误页面 - 开始访问 http:localhost 出现以下页面
- 首先当然是下载Apache 的包了,下载之后放到磁盘中
-

浙公网安备 33010602011771号