[英]Virtual host shows directory structure
目標 : - 正確設置虛擬主機。
目前我正在研究MAC系統版本10.10.05 os x yosemite。
我使用XAMPP配置了apache2,php和mysql
我已經按照配置虛擬主機的所有必要步驟進行操作。
我的文件/private/etc/apache2/extra/httpd-vhosts.conf就像
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName emsv2l.localhost.com
ServerAlias emsv2l.localhost.com
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/emsv2"
ErrorLog "/private/var/log/apache2/apple.com-error_log"
CustomLog "/private/var/log/apache2/apple.com-access_log" common
ServerAdmin webmaster@dev.plutustec.com
<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName emsv2l-backend.plutustec.com
ServerAlias emsv2l-backend.plutustec.com
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/emsv2-backend/public“
ErrorLog "/private/var/log/apache2/apple.com-error_log"
CustomLog "/private/var/log/apache2/apple.com-access_log" common
ServerAdmin webmaster@dev.plutustec.com
<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2-backend/public“>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
所以,現在,如果我寫http://emsv2l.localhost.com/
將重定向到項目,而不是它顯示目錄結構。
我的/etc/hosts
文件就像
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
#127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
#127.0.0.1 dev.local
#127.0.0.1 emsv2l-backend.plutustec.com # emsv2-backend
#127.0.0.1 emsv2l.plutustec.com # emsv2
#127.0.0.1 plutustec.com #localplutus site
127.0.0.1 emsv2l.localhost.com
127.0.0.1 emsv2l-backend.plutustec.com
任何幫助,將不勝感激。
您需要禁用目錄列表,為此替換它:
<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
附:
<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2">
Options FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
然后重新加載apache 。
有關詳細信息,請點擊此處
那么還有一件事,你在: /Applications/XAMPP/xamppfiles/htdocs/emsv2
有index.php或index.html嗎?
您是否按照指南將vhost配置為信件? 如果是這樣,您確定您配置的Apache是當前正在偵聽端口80的那個嗎? XAMPP應該內置自己的Apache,它不會運行默認配置。 您的XAMPP httpd.conf應包含:
# XAMPP VirtualHosts dir
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
要解決最快的問題:
cp -iv /private/etc/apache2/extra/httpd-vhosts.conf /Applications/XAMPP/etc/extra/httpd-vhosts.conf
如果要求覆蓋確認,請按'y'
就我而言,
我正在使用macOS Mojave(Apache / 2.4.34)。 在/etc/apache2/httpd.conf文件中搜索文本“IfModule dir_module”。 檢查IfModule指令/標記是否包含任何index.php。 如果沒有在index.html之后添加index.php。 希望這會拯救你。
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.