简体   繁体   English

如何在 xampp 中启用虚拟主机

[英]How to enable virtualhost in xampp

I am configure virtualhost on Xampp so that I can run an advanced Yii2 project (with front and backend application), I have followed this instruction and my httpd-vhosts.conf looks like this我在Xampp上配置了虚拟主机,以便我可以运行一个高级的Yii2项目(带有前端和后端应用程序),我遵循了这个指令,我的httpd-vhosts.conf看起来像这样

    <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>

while apache main port is 8081 and SSL port 4433 but it gives the error as shown on the picture bellow and the error.log says [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 how should I solve this error?虽然 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我应该如何解决此错误? I have tried several times to change the port numbers with no success.我曾多次尝试更改端口号,但均未成功。

在此处输入图片说明

On XAMPP Control Panel click on Explorer which is below Shell (This will open xampp file explorer)在 XAMPP 控制面板上单击 Shell 下方的资源管理器(这将打开 xampp 文件资源管理器)

Select and open apache folder and go to conf/extra folder Inside the xampp/apache/conf/extra folder, the file you're looking for is called httpd-ssl.conf This file deals with the SSL configuration for your XAMPP Apache installation.选择并打开 apache 文件夹并转到 conf/extra 文件夹 在 xampp/apache/conf/extra 文件夹内,您要查找的文件名为 httpd-ssl.conf 该文件处理 XAMPP Apache 安装的 SSL 配置。

Open httpd-ssl file in any editor and search for ServerName www.example.com:443在任何编辑器中打开 httpd-ssl 文件并搜索 ServerName www.example.com:443

Comment out this line by just adding # infront of it.通过在它前面添加 # 来注释掉这一行。

Next, you can add the text “ServerName winnersprimary.ac.tz” on the line directly below it.接下来,您可以在其正下方的行中添加文本“ServerName Winnersprimary.ac.tz”。

Save and close file保存并关闭文件

Restart Apache or Xampp Control panel重启 Apache 或 Xampp 控制面板

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM