一尘不染

如何在XAMPP上创建虚拟主机

php

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

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

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

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

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

阅读 252

收藏
2020-05-26

共1个答案

一尘不染

我看到两个错误:

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

一件事要提到:

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

service apache2 configtest

这将告诉您什么时候配置格式错误,甚至可以告诉您问题出在哪里。

此外,它还有助于避免LIVE系统不可用:

service apache2 restart

将关闭,然后无法启动,此配置测试您事先知道“糟糕,我做错了什么,我应该先解决此问题”,但是apache本身仍在使用旧配置运行。:)

2020-05-26