设为首页 收藏本站
查看: 771|回复: 0

[经验分享] 在Apache下开启SSI配置支持include shtml html和快速配置服务器

[复制链接]

尚未签到

发表于 2015-8-6 08:13:59 | 显示全部楼层 |阅读模式
  作为前端开发,使用Apache快速搭建服务器极为方便。
  1.找到apach安装目录,找到conf目录下 的httpd.conf
  使用SSI(Server Side Include)的html文件扩展名,SSI(Server Side Include),通常称为"服务器端嵌入"或者叫"服务器端包含",是一种类似于ASP的基于服务器的网页制作技术。默认扩展名是 .stm、.shtm 和 .shtml。



  # AddType text/html .shtml
  # AddOutputFilter INCLUDES .shtml
  把这两行前面的#去掉 添加 .html类型之后碎片引入支持.html文件了。
   AddType text/html .shtml .html
    AddOutputFilter INCLUDES .shtml .html
  然后搜索“Options Indexes FollowSymLinks”
  在搜索到的那一行后面添加“ Includes”
  即将该行改变为 Options Indexes FollowSymLinks Includes
  熟悉apache manual的可能会觉得比较容易。
  保存httpd.conf,重起apache即可
  include元素能按file属性或virtual属性判断应该包含的文件。
  file属性是一个相对于当前目录的文件路径,即不能是一个绝对路径(以"/"开头)或包含"../"的路径。
  virtual属性可能更有用,它是一个相对于被提供的文档的URL ,可以以"/"开头,但必须与被提供的文档位于同一服务器上。
  
  2.快速配置服务器 找到conf目录下 的httpd.conf

  把下面配置放在配置文件顶部即可快速搭建一个8200端口的服务器。复制该模块,修改端口和文件目录路径,即可快速搭建另外一个服务器。
  



#rho
Listen 8200
  
documentroot  "E:\work\rho"
servername  localhost:8200

Options Indexes FollowSymLinks Includes
#ErrorDocument 404 /index.shtml
    AllowOverride All
Allow from all


  
  配置文件默认配置:80端口,把端口和文件目录换成不常用的目录或端口,就可以直接吧上面快速配置服务器的配置改成80端口使用。下面的配置几乎跟上面等价。
  #Listen 12.34.56.78:80
Listen 80
  



ServerName localhost:80
#
# 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 "e:/work/xtl"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.  
#

Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#

#
    # Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
    # The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks Includes
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride all
#
    # Controls who can get stuff from this server.
#
#   onlineoffline tag - don't remove
Order Deny,Allow
allow from all
Allow from 127.0.0.1

  
  
  3.配置允许通过IP访问服务器

  
  默认的 http.conf 一段和访问控制有关的代码如下:
  
  
#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1

  
  
  
  在httpd.conf文件中,修改如下  
  
  Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
  
注意要Allow from all,这样才允许所有的IP访问。如果只是允许如下两个网段访问则:
Allow from 172.16.86.0/255.255.255.0 10.0.0.0/255.0.0.0
IP之间不是","逗号,而是空格
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-94560-1-1.html 上篇帖子: CentOS下Apache+SVN+LDAP的安装与配置 下篇帖子: Receive HTTP Message via apache httpclient
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表