Mac 升级到OS X 10.11 El Capitan 后的坑--Apache

最近闲来无事,升级了下系统,有10.7 Lion 升级到 10.11 El Capitan版本;升级的过程比较慢;升级后要更新Xcode 7.1

1、apapche 无法正常使用

  在终端中可以使用apachectl restart 命令,但是无法打开主机ip地址、localhost、127.0.0.1 等都显示无法打开,连接不到服务器;

  这就比较纠结了,没有报错就是连不上;

  网上搜的开启apache 的命令是 apahcectl - k start、restart、stop,原来一直用的是apachectl restart ;

  输入后

niko:~ xxx$ sudo apachectl -k start
Password:
AH00526: Syntax error on line 20 of /private/etc/apache2/extra/httpd-mpm.conf:
Invalid command 'LockFile', perhaps misspelled or defined by a module not included in the server configuration

  然后 按照网上搜的结果打开 http-mpm.conf文件#注释报错行,再次启动apache

(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

  好像是端口被占用,其实 好像也没多大问题换个端口就OK了;

  重新启动下就OK了;

2、Apache 使用Alias 的时候要注意,因为更新了系统后Apache 会升级到2.4 的版本;相关的Alias也要对应调整;

  

Alias /test "/Users/xxx/test"
<Directory "/Users/xxx/test">
    Options Indexes MultiViews
    AllowOverride None
    #OS X 10.9
    order allow,deny
    Allow from all
</Directory>

Alias /test "/Users/xxx/test"
<Directory "/Users/xxx/test">
    Options Indexes MultiViews
    AllowOverride None
    #OS X 10.11
    Require all granted   
</Directory>

  

相关链接

http://www.dshui.wang/2015-10-26/problem-mac-osx-10-11-eicapitan.html