【问题标题】:How to enable virtualhost in xampp如何在 xampp 中启用虚拟主机
【发布时间】:2021-09-03 19:40:44
【问题描述】:

我在 Xampp 上配置 virtualhost,以便我可以运行高级 Yii2 项目(带有前端和后端应用程序),我关注了 this instruction 和我的 @987654324 @看起来像这样

    <VirtualHost *:8081>
    ServerName winnersprimary.ac.tz
    DocumentRoot 'c:\xampp\htdocs\winnersprimary\frontend\web\'
    <Directory 'c:\xampp\htdocs\winnersprimary\frontend\web\'>
            # use mod_rewrite for pretty URL support
            RewriteEngine on
            # If a directory or a file exists, use the request directly
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            # Otherwise forward the request to index.php
            RewriteRule . index.php

            # use index.php as index file
            DirectoryIndex index.php

            # ...other settings...
            # Apache 2.4
            Require all granted
            
            ## Apache 2.2
            # Order allow,deny
            # Allow from all
        </Directory>
</VirtualHost> 

    <VirtualHost *:8081>
        ServerName admin.winnersprimary.ac.tz
        DocumentRoot 'c:\xampp\htdocs\winnersprimary\backend\web\'
        <Directory 'c:\xampp\htdocs\winnersprimary\backend\web\'>
                # use mod_rewrite for pretty URL support
                RewriteEngine on
                # If a directory or a file exists, use the request directly
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                # Otherwise forward the request to index.php
                RewriteRule . index.php
    
                # use index.php as index file
                DirectoryIndex index.php
    
                # ...other settings...
                # Apache 2.4
                Require all granted
                
                ## Apache 2.2
                # Order allow,deny
                # Allow from all
            </Directory>
    </VirtualHost>

虽然 apache 主端口是 8081SSL 端口 4433 但它给出了如下图所示的错误,error.log[Sat Jun 19 11:01:06.453372 2021] [ssl:warn] [pid 11044:tid 172] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 我应该怎么做解决这个错误?我已经尝试过多次更改端口号,但均未成功。

【问题讨论】:

    标签: php apache xampp yii2-advanced-app yii2-basic-app


    【解决方案1】:

    在 XAMPP 控制面板上单击 Shell 下面的 Explorer (这将打开 xampp 文件资源管理器)

    选择并打开 apache 文件夹并转到 conf/extra 文件夹 在 xampp/apache/conf/extra 文件夹中,您要查找的文件名为 httpd-ssl.conf 此文件处理 XAMPP Apache 安装的 SSL 配置。

    在任意编辑器中打开 httpd-ssl 文件并搜索 ServerName www.example.com:443

    只需在前面添加 # 即可注释掉这一行。

    接下来,您可以在其正下方的行中添加文本“ServerNamewinningsprimary.ac.tz”。

    保存并关闭文件

    重启 Apache 或 Xampp 控制面板

    【讨论】:

    • 非常感谢你的想法,我已经尝试过了,仍然报同样的错误
    【解决方案2】:

    我终于解决了它,我想在这里分享我的解决方案,因为它可能会帮助那里的人,我在 xammp shell 上运行 apache_start.bat 并发现以这种方式编写 DocumentRoot DocumentRoot "c:\xampp\htdocs\winnersprimary\frontend\web\" 而不是这种方式 DocumentRoot "c:/xampp/htdocs/winnersprimary/frontend/web/" 注意斜线的区别:) Click here 供参考

    【讨论】:

      猜你喜欢
      • 2021-02-10
      • 2021-08-30
      • 2019-06-11
      • 2015-09-24
      • 2016-05-11
      • 2017-10-21
      • 2020-07-29
      • 2017-01-26
      • 2020-12-17
      相关资源
      最近更新 更多