【问题标题】:apache 2.4 virtual host brings me to "Index of /"apache 2.4 虚拟主机将我带到“/索引”
【发布时间】:2018-01-17 23:45:00
【问题描述】:

我遵循了以下说明:virtual hosthttps

当我为我的 locas 托管网站使用 DynDNS 时,我的最终 000-default.conf 看起来像这样:

<VirtualHost *:443>
                ServerName www.mydomain.dyndns.xx
                ServerAdmin webmaster@localhost
                DocumentRoot /var/www/html/mydomain.dyndns.xx/
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile /etc/apache2/ssl/ca.crt
                SSLCertificateKeyFile /etc/apache2/ssl/ca.key

                ErrorLog ${APACHE_LOG_DIR}/www.virtualhost1.com_error.log
                CustomLog ${APACHE_LOG_DIR}/www.virtualhost1.com_access.log combined
</VirtualHost>

我另外在/etc/apache2/apache.conf下面配置了:

<Directory /var/www/html/mydomain.dyndns.xx>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

/etx/host

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.1.1       raspberrypi

192.168.x.x     www.mydomain.dyndns.xx

当我尝试打开页面的 URL 时,它在端口 80 上显示“Indes of /”,当我点击这些文件时,我得到 http://mydomain.dyndns.xx/mydomain.dyndns。 xx.index.php

如果我调用 https://,那么我的浏览器上会出现 ERR_CONNECTION_REFUSED。

感谢您的帮助!

【问题讨论】:

    标签: ssl-certificate virtualhost indexof self-signed apache2.4


    【解决方案1】:

    您的 000-defualt.conffile 看起来很完美 file 。虽然在使用 SSL 证书时,请确保进行以下更改:

    编辑 PORTS.CONF 文件

    编辑您的ports.conf 文件并添加以下行:

        Listen 192.168.x.x:443 
    

    这告诉 apache 监听来自指定 Ip 的传入连接:端口 443

    在本地主机上测试配置

    您可以先在/etc/hosts 文件中输入以下条目来测试系统上的配置:

        127.0.0.x    www.mydomain.dyndns.xx
    

    并将以下内容添加到ports.conf 文件中:

        Listen 127.0.0.x:443
    

    确保在测试配置之前注释掉ports.conf 文件中的192.168.x.x www.mydomain.dyndns.xx 条目

    启用 MOD_SSL

    通过发出以下命令启用mod_ssl

        sudo a2enmod ssl
    

    重新启动 APACHE

    重启apache2:sudo systemctl restart apache2

    在您的浏览器中指向您的域名:https://www.mydomain.dyndns.xx

    【讨论】:

      猜你喜欢
      • 2014-11-10
      • 1970-01-01
      • 2017-03-22
      • 2017-04-16
      • 2014-12-28
      • 2015-04-10
      • 2017-03-04
      • 2014-01-27
      • 1970-01-01
      相关资源
      最近更新 更多