macos 删除 MAMP 后从终端启动 apache 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6671042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:09:51  来源:igfitidea点击:

Error starting apache from terminal after removing MAMP

apachemacosterminalmamp

提问by redconservatory

I removed MAMP recently.

我最近删除了 MAMP。

When I try to start apache from Terminal using:

当我尝试使用以下命令从终端启动 apache 时:

sudo apachectl -k restart

I am getting the message

我收到消息

Warning: DocumentRoot [usr/docs/dummy-host.example.com] does not exist.

回答by Jared Cobb

First, make sure you're actually trying to execute the proper version of apachectl by issuing the following command:

首先,通过发出以下命令确保您实际上是在尝试执行正确版本的 apachectl:

which apachectl

(You don't want to see any MAMP references there).

(您不想在那里看到任何 MAMP 引用)。

Next, find your virtual hosts config (which is likely here if your MAMP references are gone)

接下来,找到你的虚拟主机配置(如果你的 MAMP 引用消失了,它可能在这里)

/etc/apache2/extra/httpd-vhosts.conf

Make sure your virtual host definitions are good. (Sounds like you're referencing a bad one).

确保您的虚拟主机定义良好。(听起来你在引用一个坏的)。

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/Users/yourusername/Sites/mysite"
    ServerName mysite.local
    ErrorLog "/private/var/log/apache2/mysite-error_log"
    CustomLog "/private/var/log/apache2/mysite-access_log" common
</VirtualHost>

(If you're using a custom server name other than 'localhost' like I've defined above, just be sure your /etc/hosts file is up to date with that entry like this:

(如果您使用的是我上面定义的“localhost”以外的自定义服务器名称,请确保您的 /etc/hosts 文件与该条目保持同步,如下所示:

127.0.0.1          mysite.local

Don't forget to restart apache!

不要忘记重新启动apache!

sudo apachectl restart

回答by che

You probably need to go to apache config file (something like etc/apache2/apache2.conf) and set it an existing document root directory. That is usually done with DocumentRootdirective in this file, or one of the included virtual host config definitions.

您可能需要转到 apache 配置文件(类似于etc/apache2/apache2.conf)并将其设置为现有文档根目录。这通常使用DocumentRoot此文件中的指令或包含的虚拟主机配置定义之一来完成。

回答by charlchad

Make sure you comment out all the lines inside the /etc/apache2/extra/httpd-vhosts.conf file otherwise you will get the errors.

确保注释掉 /etc/apache2/extra/httpd-vhosts.conf 文件中的所有行,否则会出现错误。