首页 > 解决方案 > 无法在 Mac 上使用端口 80

问题描述

我使用的是 macOS Catalina 10.15 版。一开始,我可以使用MAMP PRO和 Port 80。但是,由于缺少PHP的扩展ext-zip,我无法composer install在项目中运行后,如下所示:/applications/mamp/htdocts/project/

Problem 1
    - Installation request for phpoffice/phpspreadsheet 1.10.0 -> satisfiable by phpoffice/phpspreadsheet[1.10.0].
    - phpoffice/phpspreadsheet 1.10.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
Problem 2
    - phpoffice/phpspreadsheet 1.10.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - maatwebsite/excel 3.1.17 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.10.0].
    - Installation request for maatwebsite/excel 3.1.17 -> satisfiable by maatwebsite/excel[3.1.17].

我决定php通过homebrew终端安装。通过以下命令安装成功后

brew install php@7.3
# php -v
PHP 7.3.8 (cli) (built: Aug 24 2019 19:38:14) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
#which php
/usr/bin/php

结果,我不能再使用端口80的MAMP PRO ,也不能解决缺少扩展ext-zip 的问题。

我有几个问题无法解决:

  1. 如果built-in php一直在那里,我怎么能一开始就使用端口80
  2. macOS 总是在built-in php运行吗?如何知道项目内部正在使用哪个 php?(macOS 或 MAMP)??

我试过的:
- 尝试卸载php我安装的版本brew uninstall php@7.3 --force

标签: phpmacos

解决方案


没有 root 凭据的普通用户无法使用从 1 到 1024 的端口。您可以使用 sudo 绑定到端口 80,但请注意,使用 root 凭据启动程序时可能存在一些安全风险,因此请使用绑定到您的特权端口并将用户凭据放宽到普通用户的包装器.


推荐阅读