未找到虚拟主机对象

问题描述 投票:0回答:1

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

找不到对象!在此服务器上找不到请求的URL。如果您手动输入网址,请检查拼写,然后重试。如果您认为这是服务器错误,请与网站管理员联系。错误404子项目测试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文件夹

如果您能帮助我解决此问题,将不胜感激

apache ubuntu xampp virtualhost
1个回答
0
投票

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

在每个VirtualHost中定义DirectoryIndex

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


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

© www.soinside.com 2019 - 2024. All rights reserved.