Apache Reference Manual (12)

 更新时间:2016年11月25日 15:18  点击:1404
UseCanonicalName directive
Syntax: UseCanonicalName on|off|dns
Default: UseCanonicalName on
Context: server config, virtual host, directory
Override: Options
Compatibility: UseCanonicalName is only available in Apache 1.3 and later
In many situations Apache has to construct a self-referential URL. That is, a URL which refers back to the same server. With UseCanonicalName on (and in all versions prior to 1.3) Apache will use the ServerName and Port directives to construct a canonical name for the server. This name is used in all self-referential URLs, and for the values of SERVER_NAME and SERVER_PORT in CGIs.
With UseCanonicalName off Apache will form self-referential URLs using the hostname and port supplied by the client if any are supplied (otherwise it will use the canonical name). These values are the same that are used to implement name based virtual hosts, and are available with the same clients. The CGI variables SERVER_NAME and SERVER_PORT will be constructed from the client supplied values as well.
An example where this may be useful is on an intranet server where you have users connecting to the machine using short names such as www. You'll notice that if the users type a shortname, and a URL which is a directory, such as http://www/splat, without the trailing slash then Apache will redirect them to http://www.domain.com/splat/. If you have authentication enabled, this will cause the user to have to reauthenticate twice (once for www and once again for www.domain.com). But if UseCanonicalName is set off, then Apache will redirect to http://www/splat/.
There is a third option, UseCanonicalName DNS, which is intended for use with mass IP-based virtual hosting to support ancient clients that do not provide a Host: header. With this option Apache does a reverse DNS lookup on the server IP address that the client connected to in order to work out self-referential URLs.
Warning: if CGIs make assumptions about the values of SERVER_NAME they may be broken by this option. The client is essentially free to give whatever value they want as a hostname. But if the CGI is only using SERVER_NAME to construct self-referential URLs then it should be just fine.
一、前期准备情况 Apache2(Win32) 完全模块化安装perl,php,ssl
  1、一个安装好的WIN2000服务器,注意:如果你的机器上已经安装了IIS,将IIS里的所有web站点停掉或端口先改成别的。
  2、下载软件
APACHE 2.0.48
Perl 4.3.1
PHP 4.3.1
MYSQL 4.0.12
ZendOptimizer
  还有几个小东西,很重要,后面的安装会用到(不会全用到,有些文件是编译好的,可以直接用)
  下载地址1: http://www.xdiy.net/soft/serv.rar
  下载地址1: http://www.techxy.com/xdiy/serv.zip
  包里面是:mod_perl 1.9/ mod_ssl 2.0.43/ OpenSSL 0.9.6h/ mod_jk/ ApacheModuleGzip.dll
  gd 2.0.9/ gdpm/ perldiver 1.1/ 中文php.ini/editplus /php_gd_gif.dll 等
  二、安装开始
  1、APACHE安装
  1.1:运行apache_2.0.44-win32-x86-no_ssl.msi,
  假设我的安装的默认路径是 X: ,这样就安装在x盘下的APACHE2的路径下,同时默认域为domain.com。
  1.2:(作一个虚拟主机,此步可以不做)
  编辑X:apache2confhttpd.conf
  找到 #NameVirtualHost *
  修改为 NameVirtualHost 192.168.0.1 #注意这个IP为你自己主机设的IP
  找到 ServerName domain.com 修改为 #ServerName domain.com
  找到ServerAdmin * (*是你安装apache时所填写的邮箱地址)修改为 #ServerAdmin
  接下来添加以下语句:#……的是我的注释,不用加,看一下就可以了
<VirtualHost 192.168.0.1>
ServerAdmin webmaster@domain.com
#主机管理员(联系人)的邮箱地址
ServerName domain.com
#主机名(主机头名)
ServerAlias domain.com www1.domain.com
#主机名(同样可以生效的主机头名)
document.oot X:/VirtualHost/domain.com/www.domain/wwwroot
#该虚拟主机的的www根目录.
ErrorLog X:/VirtualHost/domain.com/www.domain/logs/www.domain-error_log
#错误日志文档,也可以是../logs/www.domain-error_log
CustomLog X:/VirtualHost/domain.com/www.domain/logs/www.domain-access_log common
ScriptAlias /cgi-bin /cgi-bin
#指定perl脚本运行目录,当然,不指定的话整个目录全部可以运行
ScriptAlias /php4/ "/php-bin"
#指定php脚本运行目录,当然,不指定的话整个目录全部可以运行
IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
#AddDescription "GZIP compressed document" .gz
#AddDescription "tar archive" .tar
#AddDescription "GZIP compressed tar archive" .tgz
ReadmeName README
HeaderName HEADER
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
当一个HTTP请求的URL为一个目录的时候,服务器返回这个目录中的索引文件。但如果一个目录中不存在缺省的索引文件,并且该服务器又许可显示目录文件列表的时候,就会显示出这个目录中的文件列表,为了使得这个文件列表能具有可理解性,而不仅仅是一个简单的列表,就需要前面的这些设置参数。
如果使用了IndexOptions FancyIndexing选项,可以让服务器产生的目录列
表中针对各种不同类型的文档引用各种图标。而哪种文件使用哪种图标,则使用
下面的 AddIconByEncoding、AddIconByType以及AddIcon来定义,分别依据MIME 的编码、类型以及文件的后缀来判断使用何种图标。如果不能确定文档使用的图标,就使用 DefaultIcon定义的缺省图标。
准备工作:
在http://www.apache.org下载apache_2.0.44-win32-x86-no_ssl.exe
在http://www.php.net下载php-4.3.0-Win32.zip
安装步骤:
1、运行apache_2.0.44-win32-x86-no_ssl.exe 进行默认安装到结束
2、解压php-4.3.0-Win32.zip到c:
3、拷贝文件c:php-4.3.0-Win32php.ini-dist到Windows目录下,并改名为php.ini,也把c:php-4.0.3-Win32php4ts.dll拷贝到windowssystem目录下(For Win98)或拷贝到winntsystem32目录下(For NT4/NT5)。
4、用记事本编辑文件C:Program FilesApache GroupApache2confhttpd.conf
加入两行:
LoadModule php4_module c:/php-4.3.0-Win32/sapi/php4apache2.dll
AddType application/x-httpd-php .php
5、重新启动Apache,整个安装过程结束,就这么简单,其实就是在httpd.conf中加上php模块。。。
测试:
1、用记事本写个test.php文件,保存到C:Program FilesApache GroupApache2htdocs下,内容如下:
<?php phpinfo(); ?>
2、打开浏览器运行:http://localhost/test.php
嘿嘿,够简单了吧
在windows平台上使用php+xslt
1。到http://www.php.net下载php 4.0.6
2。将php-4.0.6-Win32.zip解压到c:php下
3。在web server上配置好php
3。拷贝dlls目录下的下列四个文件到windowssystem(32)下
expat.dll
sablot.dll
xmlparser.dll
xmltok.dll
4。修改php.ini
修改extension_dir指向正确的extension目录
extension_dir = c:/php/extensions
然后找到下面这行
;extension=php_sablot.dll
修改为:
extension=php_sablot.dll
如果php配置的是cgi模式,则不需要重启web server,否则可能需要重启web server
5。我们用例子来测试一下
test.xml
============================
<?xml version="1.0"?>
<articles>
<article>
This is the first article.
</article>
</articles>
test.xsl
============================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
<html>
<body>
<xsl:value-of select="articles/article"/>
</body>
</html>
     </xsl:template>
</xsl:stylesheet>
test.php
===========================
<?php
$parser=xslt_create();
xslt_run($parser,'test.xsl','test.xml');
print xslt_fetch_result($parser);
xslt_free($parser);
?>
最后,该parser不支持GB2312。:(
[!--infotagslink--]

相关文章

  • Lua语言新手简单入门教程

    这篇文章主要给大家介绍的是关于Lua语言新手入门的简单教程,文中通过示例代码一步步介绍的非常详细,对各位新手们的入门提供了一个很方便的教程,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧。...2020-06-30
  • lua读取redis数据的null判断示例代码

    最近在工作中遇到了一个问题,通过查找相关资料才得知原因是因为返回结果的问题,下面这篇文章主要给大家介绍了关于lua读取redis数据的null判断的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考下...2020-06-30
  • Django def clean()函数对表单中的数据进行验证操作

    这篇文章主要介绍了Django def clean()函数对表单中的数据进行验证操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-07-09
  • C#中out与ref的区别实例解析

    这篇文章主要介绍了C#中out与ref的区别实例解析,对C#初学者有不错的学习借鉴价值,需要的朋友可以参考下...2020-06-25
  • 记一次EFCore类型转换错误及解决方案

    这篇文章主要介绍了记一次EFCore类型转换错误及解决方案,帮助大家更好的理解和学习使用asp.net core,感兴趣的朋友可以了解下...2021-09-22
  • Vue3中reactive函数toRef函数ref函数简介

    这篇文章主要介绍了Vue3中的三种函数,分别对reactive函数toRef函数以及ref函数原理及使用作了简单介绍,有需要的朋友可以借鉴参考下...2021-09-24
  • Apache启动报错No space left on device: AH00023该怎么解决

    Apache启动报错No space left on device: AH00023错误可能是进程导致了,虽然小编不知道什么原因但网上提供的解决办法确实是可以解决我们的问题,下面来看看。对于这类错误是因为linux系统的ipc信号量造成的,apache启动时...2015-10-21
  • c#基础系列之ref和out的深入理解

    有过C#基础知识的都应该清楚Ref和Out的使用方法,所以下面这篇文章主要给大家介绍了关于c#基础系列之ref和out的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧...2020-06-25
  • apache配置黑名单和白名单及账户权限控制

    本文我们将分享apache配置黑名单和白名单,apache层的账户权限控制,以及apache黑名单白名单过滤功能,apache rewrite规则实现白名单。 apache配置黑名单和白名单的两...2016-09-14
  • Lua判断变量是否为数字、字符串是否可以转换为数字等

    这篇文章主要介绍了Lua判断变量是否为数字、字符串是否可以转换为数字等,本文讲解了Lua 判断是字符还是数字的方法、Lua判断数字的方法、判断可否转换为数字的方法、判断并且准备一个初值的方法,需要的朋友可以参考下...2020-06-30
  • apache开启gzip详解教程

    今天在用百度工具检测时发,发现有个提示如下 原来可以开启gzip啊,因为我的是apache所以和iis不同,经过网站搜索开启方法如下 一,找到你的httpd.conf文件,打开找到如下 ...2016-01-28
  • 解决PHPstudy Apache无法启动的问题【亲测有效】

    这篇文章主要介绍了PHPstudy Apache无法启动的问题及解决方法【亲测有效】,本文给大家总结了三种方法供大家参考,需要的朋友可以参考下...2020-10-30
  • apache http server遇到了一个问题,需要关闭

    重装系统后,重新安装了xamp,最近启动的时候经常报apache http server遇到了一个问题,需要关闭,显示如图: 解决方法:查看szModName报错的模块,然后把PHP安装目录下对应的模块...2016-01-28
  • Windows Server 2016 上配置 APACHE+SSL+PHP+perl的教程详解

    Windows Server 2016 上配置 APACHE+SSL+PHP+perl怎么配置?小编推荐了一篇介绍Windows Server 2016 上配置 APACHE+SSL+PHP+perl的教程,有需要的同学快来看看吧! ...2017-07-06
  • nginx+apache+mysql+php+memcached+squid搭建集群web环境

    当前,LAMP开发模式是WEB开发的首选,如何搭建一个高效、可靠、稳定的WEB服务器一直是个热门主题,本文就是这个主题的一次尝试。...2016-01-27
  • 详解Ref在React中的交叉用法

    众所周知,react推出了hooks之后,很多项目就开始往hooks上靠拢,所以也就出现了class和hooks交叉使用的项目。这个时候使用ref需要注意一些东西...2021-06-20
  • Lua流程控制语句if else的使用示例

    今天小编就为大家分享一篇关于Lua流程控制语句if else的使用示例,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧...2020-06-30
  • 隐藏Nginx或Apache以及PHP的版本号的方法

    这篇文章主要介绍了隐藏Nginx或Apache以及PHP的版本号的方法,主要用来防止针对性的漏洞攻击,需要的朋友可以参考下...2016-01-05
  • apache下设置缓存方法详细介绍

    默认情况下,apache安装完以后,是不允许被cache的。如果外接了cache或squid服务器要求进行web加速的话,就需要在htttpd.conf里进行设置,当然前提是在安装apache的时候要激活mod_c...2016-01-28
  • Lua的table库函数insert、remove、concat、sort详细介绍

    这篇文章主要介绍了Lua的table库函数insert、remove、concat、sort详细介绍,本文分别给出了这几个函数的使用实例,需要的朋友可以参考下...2020-06-30