本文介绍了如何在 XAMPP 上创建虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信这个问题已经被问过很多次了,但我没有遇到任何问题.我使用 XAMPP 配置 Zend 框架.

I am sure this question is being asked many times but I am not encounter with a problem. I am using XAMPP where I configure Zend framework.

XAMPP 正在端口 8081 上运行,因为 80 被一些 Windows 进程占用我需要使用虚拟主机,我在 C 中使用以下代码配置:/xampp/apache/config/extra/httpd-vhosts.config(或在较新版本中为 C:/xampp/apache/conf/extra/httpd-vhosts.conf).

XAMPP is running on port 8081 as 80 is being occupied by some Windows process I need to use virtual host for that I configure with following code in C:/xampp/apache/config/extra/httpd-vhosts.config (or C:/xampp/apache/conf/extra/httpd-vhosts.conf in newer releases).

<VirtualHost *:80>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp/htdocs/CommunicationApp/public"
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

并使用 127.0.0.1 comm-app.local 更新主机文件并尝试重新启动 apache,但它显示错误.

and also update the hosts file with 127.0.0.1 comm-app.local and try to re-start apache but it is showing error.

15:03:01  [Apache]  Error: Apache shutdown unexpectedly.
15:03:01  [Apache]  This may be due to a blocked port, missing dependencies,
15:03:01  [Apache]  improper privileges, a crash, or a shutdown by another method.
15:03:01  [Apache]  Press the Logs button to view error logs and check
15:03:01  [Apache]  the Windows Event Viewer for more clues
15:03:01  [Apache]  If you need more help, copy and post this
15:03:01  [Apache]  entire log window on the forums

推荐答案

我看到两个错误:

<VirtualHost *:80> -> Fix to :8081, your POrt the server runs on
    ServerName comm-app.local
    DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
    SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp/htdocs/CommunicationApp/public" -> This is probably why it crashes, missing >
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
 -> MIssing close container: </VirtualHost>

固定版本:

<VirtualHost *:8081>
    ServerName comm-app.local
    DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
    SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp/htdocs/CommunicationApp/public">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

有一点值得一提:

您可以随时尝试运行命令:

You can always try and run command:

service apache2 configtest

这会告诉您什么时候出现了格式错误的配置,甚至可能会告诉您问题出在哪里.

This will tell you when you got a malformed configuration and maybe even can tell you where the problem is.

此外,它还有助于避免在实时系统中不可用:

Furthermore it helps avoid unavailability in a LIVE system:

service apache2 restart

将关闭然后无法启动,这个配置测试你事先知道哎呀我做错了什么,我应该先解决这个问题"但是apache本身仍然以旧配置运行.:)

will shutdown and then fail to start, this configtest you know beforehand "oops I did something wrong, I should fix this first" but the apache itself is still running with old configuration. :)

这篇关于如何在 XAMPP 上创建虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 11:52