在Xampp Windows 10中创建虚拟主机

问题描述 投票:2回答:3

昨晚我将Windows 7更新到了Windows 10。

结果是努力尝试在Windows 7上运行的Windows 10中运行我的本地apache服务器。我已经尝试卸载并安装另一个版本的xampp然后我提出我必须更改apache的默认端口才能使其运行。

我改了httpd.conf

Listen 80Listen 1234

ServerName localhost:80ServerName localhost:1234

并在xampp控制面板中配置 - >服务和端口设置。我也改变了主要港口enter image description here

现在我可以使用localhost:1234/phpmyadmin访问phpmyadmin。现在我的问题是创建虚拟主机

所以我在我的主机(C:\ Windows \ System32 \ drivers \ etc \ hosts)文件中添加了

127.0.0.1       sample.local
127.0.0.1       anothersample.local

和我的vhost(D:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf)文件

<VirtualHost *:1234>
    DocumentRoot "D:/xampp/htdocs/sample"
    ServerName sample.local
</VirtualHost>

<VirtualHost *:1234>
    DocumentRoot "D:/xampp/htdocs/anothersample"
    ServerName anothersample.local
</VirtualHost>

我确实确保上面的vhost文件包含enter image description here

我已经重新启动了我的apache但似乎我的虚拟机没有工作。任何人都可以指出我错过了什么?

apache xampp
3个回答
7
投票

谢谢@ShamSUP和@ maytham-ɯɐɥıλɐɯ我能够通过卸载xampp来解决我的问题。

然后按照说明here

我将列出我在这里所做的步骤。

  1. Windows + R并键入appwiz.cpl并使用打开或关闭Windows功能并通过展开Internet Information Services-> Web Management Tools->然后检查IIS Management Console来安装IIS管理器控制台
  2. Windows + R并输入InetMgr.exe并输入,然后展开Site右键单击它然后单击Edit Bindings
  3. 将http端口从80更改为8080

之后,我然后安装XAMPP并配置虚拟主机

主机(C:\ Windows \ System32 \ drivers \ etc \ hosts)文件

127.0.0.1       sample.local
127.0.0.1       anothersample.local

vhost(D:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf)文件

<VirtualHost *:80>
    DocumentRoot "D:\xampp\htdocs\sample"
    ServerName sample.local
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:/xampp/htdocs/anothersample"
    ServerName anothersample.local
</VirtualHost>

默认情况下,Windows虚拟主机是uncommentedenter image description here

重新启动apache和mysql之后。虚拟主机现在正在运行。我希望这可能在将来帮助某人。


1
投票

E:\ XAMPP \ apache的\的conf \额外\的httpd-vhosts.conf

</VirtualHost>
  <VirtualHost *:80>
    DocumentRoot "E:/xampp/htdocs/dev2017/schools"
    ServerName dev.schools
    <Directory "E:/xampp/htdocs/dev2017/schools">

    </Directory>
</VirtualHost>

C:\ WINDOWS \ SYSTEM32 \ DRIVERS \ ETC \主机

127.0.0.1       dev.schools

注意:减去Xampp服务器。

输入网址:http://dev.schools


1
投票

也许我的问题不同了。以上答案对我不起作用Windows 10,XAMPP便携式5.6.30

我的XAMPP在端口80上运行,但是当我设置虚拟主机时,它的localhost也会转到虚拟主机文件夹。所以http://localhost也显示了http://mydrupal的内容

我只是将它添加到/apache/conf/extra/httpd-vhosts.conf文件中。

<VirtualHost *:80>
    DocumentRoot "D:/xampp/htdocs"
    ServerName localhost
    <Directory D:/xampp/htdocs>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Windows 7上不需要上面的代码。

对于虚拟主机 - mydrupal

<VirtualHost *:80>
DocumentRoot "D:/vhosts/drupal"
ServerName mydrupal
<Directory D:/vhosts>
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

希望这可以帮助。

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