macos 升级后 从前的 apachectl 错误, php 错误
macOS 总在升级,然后,总会出现一些以前的东西无法使用!
很久不使用本机的 apache 和 php 7.2 ,今天想用的时候,发现无法使用了!
2 年前曾经重装了本机的 apache MacBook 重装 Apache 和 PHP 7.2
当前版本
$ sw_vers
ProductName: macOS
ProductVersion: 11.4
BuildVersion: 20F71
经验教训
- Mac 本机自带 Apache ,能用就好!发证也不可能用于生产环境!
- 不要轻易改动原生的环境,因为你下次升级后,你的改动不定会出现啥情况
1、错误: apache 和 php 都不对
$ sudo apachectl -k start
httpd: Syntax error on line 193 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php/lib/httpd/modules/libphp7.so, 10): Library not loaded: /usr/lib/libpq.5.dylib\n Referenced from: /usr/local/opt/php/lib/httpd/modules/libphp7.so\n Reason: image not found
$ php
dyld: Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Abort trap: 6$ sudo /usr/local/bin/apachectl -k restart
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 机器名XXX.local. Set the ‘ServerName’ directive globally to suppress this message
httpd not running, trying to start
2、定位 apachectl 和 httpd 错误
$ which apachectl
/usr/local/bin/apachectl$ whereis apachectl
/usr/sbin/apachectl$ sudo vim /etc/apache2/httpd.conf
找到 libphp7.so 的这一行,去掉注释 ## by wzh 20210617LoadModule php7_module libexec/apache2/libphp7.so
$ sudo vim /usr/local/etc/httpd/httpd.conf
找到 2 年前修改的 libphp7.so 的这一行,注释掉!
因为错误提示加载不上!
按照 /etc/apache2/httpd.conf 直接 cp 过来# by wzh 20190718 enable php7 (cp from /etc/apache2/httpd.conf)# do not exist after brew install php 72# LoadModule php7_module libexec/apache2/libphp7.so# add by wzh 20190718 accord brew install 7.2# LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so# 20210617 (cp from /etc/apache2/httpd.conf)LoadModule php7_module libexec/apache2/libphp7.so
再加上 ServerName !从前是不需要的!
#ServerName www.example.com:8080# 20210617ServerName localhost
开始一直折腾的 which apachectl 找到的 apachectl 所对应的 httpd.conf ,死活都不行!
想着干脆恢复到系统自带 apache ,于是 whereis apachectl,也尝试修改了他的对应 httpd.conf
之后,再同样修改 which apachectl 对应的 httpd.conf
然后,神奇的就 ok了!$ sudo brew services start httpd
Service `httpd` already started, use `brew services restart httpd` to restart.
$ sudo brew services restart httpd
Stopping `httpd`... (might take a while)==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd)Warning: Taking root:admin ownership of some httpd paths:/usr/local/Cellar/httpd/2.4.34/bin/usr/local/Cellar/httpd/2.4.34/bin/httpd/usr/local/opt/httpd/usr/local/var/homebrew/linked/httpdThis will require manual removal of these paths using `sudo rm` onbrew upgrade/reinstall/uninstall.Warning: httpd must be run as non-root to start at user login!==> Successfully started `httpd` (label: homebrew.mxcl.httpd)
3、定位 php 错误
$ ls /usr/lib/libpq.5.dylib
ls: /usr/lib/libpq.5.dylib: No such file or directory
不存在这个文件啊!
$ ls /usr/lib/libp*
/usr/lib/libpython.dylib /usr/lib/libpython2.7.dylib
只有其他类似的 dylib 文件参考
https://forum.sublimetext.com/t/big-sur-upgrade-error-dyld-library-not-loaded-usr-lib-libpq-5-dylib-referenced-from-usr-local-bin-php-reason-image-not-found/55119/3这个 otool 是个啥工具?咱不懂!照着用先!
$ otool -L /usr/local/bin/php
/usr/local/bin/php:
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
…
/usr/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.6.0)
…$ otool -L /usr/local/bin/php |grep libpq
/usr/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.6.0)$ brew link libpq
Warning: libpq is keg-only and must be linked with --force
If you need to have this software first in your PATH instead consider running:
echo ‘export PATH="/usr/local/opt/libpq/bin:$PATH"’ >> /Users/dhbm/.bash_profile$ brew link libpq --force
Linking /usr/local/Cellar/libpq/10.4… 350 symlinks createdIf you need to have this software first in your PATH instead consider running:
echo ‘export PATH="/usr/local/opt/libpq/bin:$PATH"’ >> /Users/dhbm/.bash_profile$ php -v
PHP 7.2.8 (cli) (built: Jul 19 2018 12:15:24) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright © 1998-2018 Zend Technologies
with Xdebug v2.7.2, Copyright © 2002-2019, by Derick Rethans
with Zend OPcache v7.2.8, Copyright © 1999-2018, by Zend Technologies
终于恢复可用状态了!
4、 其他
- 按照 https://php-osx.liip.ch/ 说明,尝试重新安装 php 7.3 ,php7.2 都不行!
$ curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
expr: syntax error
expr: syntax error
****
Your version of OS X () is not supported, you need at least 10.6
Stopping installation...
If you think that's wrong, try
****
curl -o install.sh -s https://php-osx.liip.ch/install.sh | bash install.sh force
****
dhbm-on-mac20180816:apache2 dhbm$ php -v
dyld: Library not loaded: /usr/lib/libpq.5.dylibReferenced from: /usr/local/bin/phpReason: image not found
Abort trap: 6
- httpd 端口占用,死活找不到冲突之处!先吃饭,回来他自己就好了!?
$ httpd -v
Server version: Apache/2.4.34 (Unix)
Server built: Jul 14 2018 08:30:33
$ httpd
(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
只能重启电脑之后再来验证!
reboot 之前 , PATH 设置记得加上echo ‘export PATH="/usr/local/opt/libpq/bin:$PATH"’ >> /Users/dhbm/.bash_profile
重启后回来,测试一下!
$ apachectl -vServer version: Apache/2.4.34 (Unix)
Server built: Jul 14 2018 08:30:33$ php -v
PHP 7.2.8 (cli) (built: Jul 19 2018 12:15:24) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright © 1998-2018 Zend Technologies
with Xdebug v2.7.2, Copyright © 2002-2019, by Derick Rethans
with Zend OPcache v7.2.8, Copyright © 1999-2018, by Zend Technologies
后记
下午再测试,发现又不对了!
以上命令行正确
但是 restart apache 就不对!
$ sudo apachectl restarthttpd: Syntax error on line 195 of /usr/local/etc/httpd/httpd.conf: Cannot load libexec/apache2/libphp7.so into server: dlopen(/usr/local/opt/httpd/libexec/apache2/libphp7.so, 10): image not found
还是这个错误啊!
- 可能是服务的路径不对!
$ ps -ef |grep apache
501 2160 2110 0 4:06下午 ttys001 0:00.00 grep apache
$ ps -ef |grep http
501 2163 2110 0 4:06下午 ttys001 0:00.00 grep http
都没有启动啊!
$ sudo vim /usr/local/etc/httpd/httpd.conf
# by wzh 20190718 enable php7 (cp from /etc/apache2/httpd.conf)# do not exist after brew install php 72# LoadModule php7_module libexec/apache2/libphp7.so# add by wzh 20190718 accord brew install 7.2LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so# by wzh 20210617 (cp from /etc/apache2/httpd.conf)# LoadModule php7_module libexec/apache2/libphp7.so
还是使用以前那个 libphp7.so
4. 重启服务,先启动 httpd ,再启动 apachectl
$ sudo brew services restart httpd
不需要 apachectl 了 ?!
$ sudo apachectl restart
$ ps -ef |grep httpd 验证一下
- 测试 curl 127.0.0.1 ,在浏览器上也测试一下!
macos 升级后 从前的 apachectl 错误, php 错误相关推荐
- 解决MacOS升级后出现xcrun: error: invalid active developer path, missing xcrun的问题
最近MacOS升级了MacOs Mojave ,在终端里(以及在pycharm的Project Interpreter里)使用命令行安装模块的时候,弹出一行莫名其妙的错误: xcrun: error: ...
- macOS 更新后 Git 无法工作(xcrun: 错误:无效的活动开发者路径 (/Library/Developer/CommandLineTools)
问: 我更新到 macOS Mojave(这也发生在 Catalina 更新中,并且似乎可能发生在此后的每次重大更新中) 今天早上,我在 MacBook Pro 的命令行中导航到我工作的代码库,在存储 ...
- MacOS 升级后出现 xcrun: error: invalid active developer path, missing xcrun
升级macOS mojove,终端里使用git的时候,弹出一行莫名其妙的错误: xcrun: error: invalid active developer path (/Library/Develo ...
- 快速解决macOS升级后截图权限授予无效的问题
问题 macOS的新版系统Bug Sur也发布了大半年了,今天终于下决心升级.都11.4了,应该挺稳定了吧.结果没想到还是有一些小坑. 很多软件都需要一项叫"屏幕录制"的权限,一般 ...
- M1中WMware Fusion Win11虚拟机在MacOS升级后无法联网和修改显示分辨率的解决办法
(1)以管理员身份在powershell中运行Set-Executionpolicy Remotesigned (2)安装VMware Tools,再打开WMware tools所在文件夹中,找到se ...
- 百胜系统连接服务器失败,MySQL服务器无法在百胜升级后启动
在我的CentOS云服务器上执行yum更新后,MySQL无法启动.MySQL服务器无法在百胜升级后启动 在网页搜索的错误后: Can't connect to local MySQL server t ...
- MacOS升级之后导致MySQL无法启动
MacOS升级之后导致MySQL无法启动 本周准备学习一下MySQL,于是准备启动mysql,发现一直无法开启. 一.由于MacOs升级到最新的Monterey导致一个错误: Warning:The ...
- u盘版linux initramfs,Linux_内核升级后 出现initramfs错误问题解决, 出现initramfs找不到/root /hos - phpStudy...
内核升级后 出现initramfs错误问题解决 出现initramfs找不到/root /host或437或 VFS之类的提示: 1.如果root.disk是在fat32 分区上,所以内核选项要把fa ...
- oracle 942出错,oracle升级后exp出现oracle942错误
oracle升级后exp出现oracle942错误以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 出现该错误的原因是 由 ...
- Xcode 升级后,常常遇到的遇到的警告、错误,解决方法
Xcode 升级后,常常遇到的遇到的警告.错误,解决方法 参考文章: (1)Xcode 升级后,常常遇到的遇到的警告.错误,解决方法 (2)https://www.cnblogs.com/cooka/ ...
最新文章
- NodeJS学习之网络操作
- 干活干累了,刷一道题,一天保底两道,一年也就差不多刷完了 ----------7. Reverse Integer...
- Exchange Server 2003群集系统方案
- boost::leaf::result用法的测试程序
- VisualSVN Server 不能打开文件,系统找不到指定的文件
- Keil中的Code,RO,RW,ZI分别表示什么?
- SpringCloud Gateway 快速入门_01
- Android Studio 视图解析
- 阶段3 1.Mybatis_08.动态SQL_03.mybatis中动态sql语句-foreach和sql标签
- 软件性能测试包括哪些方面,简述软件系统性能指标主要包括哪些方面
- 计算机蓝牙快捷键,电脑蓝牙怎么开,详细教您怎么打开电脑蓝牙
- 可能有用的技术社区(转载)
- Zero-shot Learning零样本学习 论文阅读(五)——DeViSE:A Deep Visual-Semantic Embedding Model
- 数据库实验 MySQL查询语句练习
- COGS 336 Vijos 1018 NOI2003 智破连环阵
- 计算机科学湖北的大学排行,2015年湖北省大学最佳专业排行榜
- 盘点国内外十大免费CDN网站加速服务
- PCI配置空间(PCI Configuration Space)
- JAVA WEB 开源CMS系统,可用来二次开发
- 就是我mac安装了虚拟机,装了win10,然后发现在mac系统桌面也会有win系统桌面的工具快捷键图标,如果删除mac桌面的快捷键图标,那么win10桌面的图标也消失了,我百度查的方法都不行。我想知道
热门文章
- Xtrabackup2.4.8备份、还原、恢复Mysql5.7.19实操
- windows安装composer总结
- freeCodeCamp:Seek and Destroy
- HTML中IE条件注释判断语句(!--[if XX IE X]![endif]--)
- 汉字取首字母(第三节蓝桥杯决赛)
- 在线编程 - PyPool小站启动记
- Linux学习笔记之查看Linux版本信息
- spring cloud config git库文件搜索顺序
- 在MingW下编译llvm/clang
- POJ 3125 Printer Queue(队列,水题)