Apache virtual contents configuratiion

来源:互联网 发布:博德之门 知乎 编辑:程序博客网 时间:2024/05/16 06:42
Apache  virtual contents configuratiion

在IIS和PWS中,该设置是通过图形界面进行的,在Apache中是编辑httpd.conf文件(该文件一般不要轻易改动),在该文件中加一行

Alias /test/ "c:/php/test/"

表示将c:/php/test/目录设置为虚拟目录/test/,那么在c:/php/test/下的文件,就可以通过在浏览器中输入“http://117.0.0.1/test/文件”访问。

   使Apache支持PHP

使Apache支持PHP,还需以下配置

在httpd.conf文件中加入以下几行:

ScriptAlias /php3/ "c:/php3/"
AddType application/x-httpd-php3 .php
Action application/x-httpd-php3 "/php3/php.exe"

如果想将php文件后缀改为其它的也可以,将第二行中的最后几个字“.php”改为想要的后缀即可,

想支持更多的文件,也可以,eg:

ScriptAlias /php3/ "c:/php3/"
AddType application/x-httpd-php3 .php
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .phtml
Action application/x-httpd-php3 "/php3/php.exe"

 then,reboot  Apache,and do a test 。

write a simple php file (hello.php) under the virtual contents of "test"

<?

echo "Hello World!";

?>

enter  "http://117.0.0.1/test/hello.php"  in the address,

use

<? phpinfo() ?> 

to check the php  configuration.

原创粉丝点击