1. 我们的apache软件 配置是在 httpd.conf 文件中配置,该文件在apache安装目录下的 conf
在 httpd.conf 文件中我们修改端口:
Listen 81
注意修改完后,一定要重新启动apache
自己安装一个apache ,把端口配置成 8000,然后测试
----------------------------------------------------------------------------------
apache的目录结构
这比较重要的文件夹
bin 、 conf 、 htdocs 、 modules
目前我们对apache有一个基本的了解.
运行机制图:
mpm : mutil processing module 多重处理模块
apr: 可移植运行库 [了解]
虚拟目录
-------------------------------------------------------------------
提一个需求:
我的apache是安装在 c盘 , 但是出现c 盘没有空间,d盘有更多空间.
,能不能把d盘的一个文件夹下的网页html, php ,当做网站管理
-------------------------------------------------------------------
看看如何完成这个功能:
1. 添加虚拟目录的节点
#配置虚拟目录
<IfModule dir_module>
#direcotory相当于是欢迎页面
DirectoryIndex index.html index.htm index.php
#你的站点别名
Alias /myblog "D:/myblog"
<Directory d:/myblog>
#这是访问权限设置
Order allow,deny
Allow from all
</Directory>
</IfModule>
2. 注销documentroot路径
#DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
3. 测试
http://localhost/myblog/news.html
4. 如何设置欢迎页面
DirectoryIndex news.html index.html index.htm index.php
5. 关于apache访问权限
order deny,allow allow from 218.20.253.2 deny from 218.20
#代表拒绝218.20开头的IP,但允许218.20.253.2通过;而其它非218开头的IP也都允许通过。
order allow,deny allow from 218.20.253.2 deny from 218.20
#和上面的差不多,只是掉换的order语句中的allow、deny先后顺序,但最终结果表示全部都拒绝!
---------------------------------------------------------------------------------------------------------------------------------------------------
看一个企业常见需求:
我们在实际访问网站的过程中,不可能使,http://localhost:80 的方式去访问网站,实际上使用类似:http://www.sina.com.cn 或者http://news.sina.com.cn 的方式去访问网站,这个又是怎么实现的呢?
如需在apache服务器中创建WEB站点,需要启用
httpd-vhosts.conf文件添加
<VirtualHost 127.0.0.1:80></VirtualHost>
note:确保dns client服务是启动状态
配置的主机(网站)要想被外部访问,必须在DNS服务器
或windows系统中注册。
配置虚拟主机的步骤如下:
启用 httpd-vhosts.conf
在 httpd.conf 文件中
# Virtual hosts ,虚拟主机
Include conf/extra/httpd-vhosts.conf
在httpd-vhosts.conf文件中做配置
#配置我们自己的虚拟主机
<VirtualHost 127.0.0.1:80>
DocumentRoot "d:/myblog"
#这里配置欢迎首页面
DirectoryIndex index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
修改hosts 文件 ->新的知识点. (重新审视我们的访问一个网页的真正流程)
www.shunping.com