Resolving Missing PHP and OpenSSL Header Files When Installing Swoole on macOS
This article documents the step‑by‑step process of fixing missing PHP and OpenSSL header files on macOS, configuring environment variables, and successfully compiling the Swoole extension using phpize, Homebrew, and manual header copying.
The author shares a detailed troubleshooting guide for installing the Swoole PHP extension on a macOS machine that uses the built‑in PHP 7.3 and the MxSrvs development environment.
Two main issues are encountered: the system cannot locate PHP header files and cannot find OpenSSL header files, both caused by the macOS default PHP lacking the necessary development files.
Preparation steps include ensuring autoconf ≥ 2.68, downloading the Swoole source from Git, and confirming the local environment (Xcode not installed, PHP 7.3 present).
To compile, the author runs the following commands inside the MxSrvs PHP directory:
/Applications/MxSrvs/bin/php/bin/phpize ./configure \--enable-openssl \--enable-http2 make && sudo make installThe first problem is solved by adding the tool’s PHP binary path to the system environment via source ~/.bash_profile (or adding the same line to ~/.zshrc) so that the required header files become reachable.
For the OpenSSL issue, the author installs OpenSSL with Homebrew: brew install openssl If OpenSSL is already present, it can be reinstalled with: brew reinstall [email protected] Then the PATH is updated by appending the following line to ~/.zshrc:
export PATH="/usr/local/opt/[email protected]/bin:$PATH"Finally, the missing OpenSSL headers are copied from the Homebrew Cellar to the Xcode SDK include directory:
/usr/local/Cellar/[email protected]/1.1.1h/include/openssl → /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/After these adjustments, the second issue is resolved, and the Swoole extension compiles successfully, as shown by the final screenshots.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
php Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
