Rumah  >  Artikel  >  pembangunan bahagian belakang  >  关于php之Apache配置虚拟主机

关于php之Apache配置虚拟主机

迷茫
迷茫asal
2017-03-26 10:20:502205semak imbas

Apache版本以2.4为例

1、修改httpd.conf

把下面第二行的#去掉,启动虚拟主机配置

# Virtual hosts  # Include conf/extra/httpd-vhosts.conf

2、配置httpd-vhost.conf

这里使用了8081端口,配置了两个虚拟主机,DocumentRoot不能含有中文目录

<VirtualHost *:8081>  
    ServerName localhost
    DirectoryIndex index.php   
    DocumentRoot "D:\Work\php\Apache24\htdocs"  
    <Directory "D:\Work\php\Apache24\htdocs">   
        Options Indexes FollowSymLinks   
        AllowOverride None   
        Order allow,deny   
        Allow from all   
    </Directory>   
</VirtualHost>  

<VirtualHost *:8081>  
    ServerName www.aa.com
    DirectoryIndex index.php   
    DocumentRoot "E:\php\PhpProjectBase"  
    <Directory "E:\php\PhpProjectBase">   
        Options Indexes FollowSymLinks   
        AllowOverride None   
        Order allow,deny   
        Allow from all   
    </Directory>   
</VirtualHost>

3、etc/hosts配置

127.0.0.1 localhost127.0.0.1 www.aa.com

4、重启Apache服务

如果此时虚拟主机仍不能访问,配置httpd.conf中以下项

<Directory />
    AllowOverride none    #Require all denied</Directory>

Atas ialah kandungan terperinci 关于php之Apache配置虚拟主机. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:php生成无限栏目树 Artikel seterusnya:详解php创建图像具体步骤