apache 中控制虚拟主机的php功能

in 服务器类

使用情况分以下两种:

一,在httpd.conf中配置了全局使用php脚本,则使用下面的方法
在虚拟主机的设置小节中添加php_flag engine on/off 字串7

如: 字串9

<VirtualHost 61.156.20.89:80>
ServerName xxxxxx.com
php_flag engine off
serveralias www.xxxxxx.com
ServerAdmin webmaster@hanxiao2000.com
DocumentRoot "/home/xxxxxx/htdocs"
</VirtualHost> haohtml.com

二.没有在httpd.conf中配置执行php脚本功能

 

 

在虚拟主机配置中这样改:

 

 

  把 AddType   application/x-httpd-php   .php   这句话放到需要运行php的虚拟主机的配置中
    
  #这个虚拟主机不能运行php  
  <VirtualHost   127.0.0.1>  
          ServerAdmin   sc@lin.net.cn  
          DocumentRoot   d:/www.haohtml.com/  
          ServerName   www.haohtml.com  
  </VirtualHost>  
   
  #这个虚拟主机可以运行php  
  <VirtualHost   127.0.0.1>  
          ServerAdmin   sc@lin.net.cn  
          DocumentRoot   d:/www.haohtml.com/  
          ServerName   www.haohtml.com  
          AddType   application/x-httpd-php   .php 
  </VirtualHost>

说明:如果要禁止某个目录禁止执行php脚本,则为
<Directory   你的图片目录>  
                <FilesMatch   "\.(php|php3)$">    
                      Deny   from   all  
                </FilesMatch>   
 </Directory>

0 Comments

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>