Mac安装最新Apache /Mac替换/usr/sbin目录文件

虽然Mac自带Apache,但是偶尔还是想升级的嘛,于是今天升级了Apache到2.4.27


1.下载安装包:

http://httpd.apache.org/download.cgi


2.解压安装包,cd到httpd-2.4.27,安装:

sudo ./configure --prefix=/etc/apache2 --with-apr=/usr/local/opt/apr --with-apr-util=/usr/local/opt/apr-util  --with-pcre=/usr/local/opt/pcre --enable-ssl --with-ssl=/usr/local/opt/openssl

sudo make && make install

PS:如果没有安装apr,apr-util,pcre,则会报错,用brew安装即可,后面对应的是相应的位置.



二。安装成功后,可以启动apache,其它的命令就不提了:

/etc/apache2/bin/apachectl -k start

但是,sbin目录下的apachectl文件还没替换,而且默认系统管理员也没有修改/usr/sbin目录下文件的权限,所以不能替换。这是由于系统启用了SIP(System Integerity Protection)导致root用户也没有修改权限,所以我们需要屏蔽掉这个功能:

1.关机,然后开机按住Command+R。

2.点击工具-终端,输入:csrutil disable,看见success就可以了,重启,就能替换sbin目录下文件

3.这时候我们再输入apachectl -v 就能看到最新版本Apache。


PS:启动 停止等等操作会报错:

AH00557: httpd: apr_sockaddr_info_get() failed for chenzheshigehaohaizideMacBook-Pro.local

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

如提示,只需要在httpd.conf文件中加上 ServerName  localhost:80 即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容