apache 2.4 虚拟主机将我带到 "Index of /"

apache 2.4 virtual host brings me to "Index of /"

我遵循了以下说明:virtual host, https

当我为我的 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。

感谢您的帮助!

您的 000-defualt.conf 文件看起来非常完美。尽管在使用 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