Homebrew Apache 在移除 MacPorts 后出现问题

Homebrew Apache 在移除 MacPorts 后出现问题

我按照他们的指南彻底删除了 MacPorts这里. 卸载所有端口,然后删除所有文件夹

sudo rm -rf \ /opt/local \ /Applications/DarwinPorts \ /Applications/MacPorts \ /Library/LaunchDaemons/org.macports.* \ /Library/Receipts/DarwinPorts*.pkg \ /Library/Receipts/MacPorts*.pkg \ /Library/StartupItems/DarwinPortsStartup \ /Library/Tcl/darwinports1.0 \ /Library/Tcl/macports1.0 \ ~/.macports

然后我安装了 homebrew、dnsmasq 和 MySQL。后两个我使用 Brew 安装,而 Apache 则希望在本机运行。现在的问题似乎是 Apache 仍然通过 Macports 运行。

ps ax | grep httpd
  254   ??  Ss     0:00.72 /opt/local/apache2/bin/httpd -k start
  258   ??  S      0:00.02 /opt/local/apache2/bin/httpd -k start
  259   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
  262   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
 1811   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
 1812   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
 1818   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
 1820   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
 1826   ??  S      0:00.02 /opt/local/apache2/bin/httpd -k start
 1857   ??  S      0:00.02 /opt/local/apache2/bin/httpd -k start
 2336   ??  S      0:00.01 /opt/local/apache2/bin/httpd -k start
 3720 s000  S+     0:00.00 grep httpd

尽管所有端口以及与 MacPorts 相关的所有文件夹都已删除,但我认为所有启动器也都已删除。现在如何加载 httpd?

另一个问题是 DocumentRoot 不会 DocumentRoot "/Library/WebServer/Documents"/etc/apache2/httpd.confnor加载默认的 documentRoot /private/etc/apache2/httpd.conf。它似乎加载了旧的 MacPorts documentRoot,但是从哪里加载呢?据我所知,所有文件和文件夹都消失了。当我检查它时,它确实显示了新的 DocumentRoot

sudo apachectl -V | grep -i SERVER_CONFIG_FILE | cut -f2 -d'"' | xargs grep -i '^DocumentRoot' | cut -f2 -d'"'
/Library/WebServer/Documents

当我卸载并加载 OSX 的 Apache 时,我确实收到一条错误消息,显示我的 vhost 已加载:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Password:
jaspersmbp:etc jasper$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
jaspersmbp:etc jasper$ apachectl
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist
AH00526: Syntax error on line 41 of /private/etc/apache2/extra/httpd-vhosts.conf:
Invalid command 'VirtualDocumentRoot', perhaps misspelled or defined by a module not included in the server configuration

但打开 localhost 仍然加载错误或旧的 DocumentRoot

这是 hosts 文件 atm

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost jaspersmbp.local wordpress.local joomla.local
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0 localhost

# My local aliases

/etc/apache2/extra/httpd-vhosts.conf这里是我使用 *dev 动态添加到加载本地域的VirtualHost

<Virtualhost *:80>
    DocumentRoot "/Users/jasper/webdesign"
    ServerName vhosts.dev
    ServerAlias *.dev
    UseCanonicalName Off
    LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
    ErrorLog "/Users/jasper/webdesign/vhosts-error_log"
    <Directory "/Users/jasper/webdesign/*">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</Virtualhost>

运行 apachectl 似乎会重新启动 MacPorts 的 Apache,但我在 $PATH 中的 .bashrc 和 .bash_profile 中都找不到它。

我的路径

echo $PATH
/Users/jasper/.rvm/gems/ruby-2.1.1/bin:/Users/jasper/.rvm/gems/ruby-2.1.1@global/bin:/Users/jasper/.rvm/rubies/ruby-2.1.1/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/jasper/.rvm/bin

问题是:

  1. 如何停止错误的幽灵 Apache 守护进程
  2. 我如何才能找到文档根目录的实际加载位置并进行更改?

答案1

我发现https://discussions.apple.com/thread/6602475表示要停止两个 httpd 进程并停止我在日志中看到的错误

11/24/14 4:53:29.105 PM com.apple.xpc.launchd[1]: (org.apache.httpd) Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

我必须使用

sudo apachectl stop
sudo killall -9 httpd

主要问题似乎是我需要终止所有正在运行的旧 httpd 进程。之后,在主机文件中创建的新主机开始正常工作。

当我检查守护进程时,我看到:

ps ax |grep httpd
 5798   ??  Ss     0:00.30 /usr/sbin/httpd -D FOREGROUND
 5799   ??  S      0:00.00 /usr/sbin/httpd -D FOREGROUND
 5800   ??  S      0:00.00 /usr/sbin/httpd -D FOREGROUND
 5801   ??  S      0:00.00 /usr/sbin/httpd -D FOREGROUND
 5802   ??  S      0:00.00 /usr/sbin/httpd -D FOREGROUND

再次。OSX 终于再次运行 Apache 节目了。

相关内容