简体   繁体   English

虚拟主机显示目录结构

[英]Virtual host shows directory structure

Goal :- set up virtual host correctly. 目标 : - 正确设置虚拟主机。

currently I am working on MAC system version 10.10.05 os x yosemite. 目前我正在研究MAC系统版本10.10.05 os x yosemite。

I have configured apache2,php and mysql using XAMPP 我使用XAMPP配置了apache2,php和mysql

I have follow all the necessary steps for configuring virtual host. 我已经按照配置虚拟主机的所有必要步骤进行操作。

my file /private/etc/apache2/extra/httpd-vhosts.conf would be like 我的文件/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>

So, Now if i write http://emsv2l.localhost.com/ would be redirect to project instead it's showing directory structure. 所以,现在,如果我写http://emsv2l.localhost.com/将重定向到项目,而不是它显示目录结构。

在此输入图像描述

my /etc/hosts file would be like 我的/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

Any help would be appreciated. 任何帮助,将不胜感激。

You need to disable directory listing, to do that replace this: 您需要禁用目录列表,为此替换它:

<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
</Directory>

With: 附:

<Directory "/Applications/XAMPP/xamppfiles/htdocs/emsv2">
        Options FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
</Directory>

Then reload apache . 然后重新加载apache

For more details check here 有关详细信息,请点击此处

Then one more thing, do you have an index.php or index.html within your: /Applications/XAMPP/xamppfiles/htdocs/emsv2 ? 那么还有一件事,你在: /Applications/XAMPP/xamppfiles/htdocs/emsv2有index.php或index.html吗?

Did you follow the guide for configuring vhosts to the letter? 您是否按照指南将vhost配置为信件? If so, are you sure that the Apache you configured is the one that is currently listening on port 80? 如果是这样,您确定您配置的Apache是​​当前正在侦听端口80的那个吗? XAMPP should have it's own Apache built in and it doesn't run off the default config. XAMPP应该内置自己的Apache,它不会运行默认配置。 Your XAMPP httpd.conf should contain: 您的XAMPP httpd.conf应包含:

# XAMPP VirtualHosts dir
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

To solve fastest just: 要解决最快的问题:

cp -iv /private/etc/apache2/extra/httpd-vhosts.conf /Applications/XAMPP/etc/extra/httpd-vhosts.conf

If asked for overwrite confirmation press 'y' 如果要求覆盖确认,请按'y'

in my case, 就我而言,

i'm using macOS Mojave (Apache/2.4.34). 我正在使用macOS Mojave(Apache / 2.4.34)。 In /etc/apache2/httpd.conf file search for the text "IfModule dir_module". 在/etc/apache2/httpd.conf文件中搜索文本“IfModule dir_module”。 Check the IfModule directive/tag contain any index.php. 检查IfModule指令/标记是否包含任何index.php。 If no the add index.php after index.html. 如果没有在index.html之后添加index.php。 Hope this will save you. 希望这会拯救你。

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM