關於phpApache設定虛擬主機

迷茫
發布: 2023-03-06 22:24:02
原創
2204 人瀏覽過

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>
登入後複製

以上是關於phpApache設定虛擬主機的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!