apache - 找不到虚拟主机对象

标签 apache ubuntu xampp virtualhost

每次我尝试访问 https://sub.myproject.test/弹出此消息:

找不到对象!
在此服务器上找不到请求的 URL。如果您手动输入了 URL,请检查您的拼写并重试。
如果您认为这是服务器错误,请联系网站管理员。
错误 404
sub.myproject.test
Apache/2.4.38 (Unix) OpenSSL/1.0.2q PHP/7.2.15 mod_perl/2.0.8-dev Perl/v5.16.3

httpd-vhosts.conf我有:

<VirtualHost *:80>
    DocumentRoot "/mnt/data/myproject/sub.myproject.com/public_html"
    ServerName sub.myproject.test
    ServerAlias www.sub.myproject.test
    <Directory  "/mnt/data/myproject/sub.myproject.com/public_html/">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

httpd-ssl.conf我有:
# catalog config
<VirtualHost *:443>
    DocumentRoot "/mnt/data/myproject/sub.myproject.com/public_html"
    ServerName sub.myproject.test:443
    ServerAlias www.sub.myproject.test:443
    ErrorLog "/opt/lampp/logs/error_log"
    TransferLog "/opt/lampp/logs/access_log"
    SSLEngine on

    SSLCertificateFile "/opt/lampp/etc/ssl.crt/server.crt"
    SSLCertificateKeyFile "/opt/lampp/etc/ssl.key/server.key"

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>

    <Directory "/mnt/data/myproject/sub.myproject.com/public_html/">
        SSLOptions +StdEnvVars +FakeBasicAuth

        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Allow from all
        Require all granted
    </Directory>
    BrowserMatch "MSIE [2-5]" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    CustomLog "/opt/lampp/logs/ssl_request_log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

当然还有 /mnt/data/myproject我有 sub.myproject.com 的路径文件夹

如果你能帮我解决这个问题,将不胜感激

最佳答案

您的 VirtualHost 没问题(除非您不需要在 ServerName 和 ServerAlias 指令中输入 :443),但是当请求中未指定时,您永远不会告诉 Apache 默认显示哪个页面。

定义 DirectoryIndex在每个虚拟主机中。

例如:DirectoryIndex index.html当请求为 https://example.com/
,因此域名后面没有任何内容,Apache 将显示 index.html,来自 DocumentRoot目录。

与您的问题无关,您应该输入 ServerTokens ProdServerSignature Off在您的配置中,您的错误消息显示了很多信息。

关于apache - 找不到虚拟主机对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58219934/

相关文章:

python - 将 REST 添加到 Django

linux - Amazon EC 2 上用户目录中的 Apache VirtualHost

无法在启用的 CPU 上使用 SSSE3

c - 简单的 libnotify "hello world"程序无法在 Ubuntu 20.04 上编译并出现链接器错误

android - 与 adb 的连接已关闭,并且发生了严重错误。 - Ubuntu 12.04

xampp - 错误启动 "XAMPP"堆栈另一个实例似乎正在 PID 455 运行

java - Hive 查询 Json 错误

使用 Tomcat 和 Max-age 指令的 Apache Mod_cache 配置

php - (PHP/MYSQL) fatal error : Class 'STemplate' not found

mysql - 如何在MySQL数据库中定义一个表来存储JSON对象?