1

Install extension for macOS built-in PHP

 2 years ago
source link: https://ooso.net/archives/764
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Install extension for macOS built-in PHP – 某人的栖息地

Skip to the content

macOS High Sierra 10.13.3 ships with PHP 7.1.7. I’m trying to install an extension for the built-in PHP. I tried the pecl command but no lucky because SIP (System Integrity Protection) protection. I can’t add file under the directory /usr/lib/php that default php extension directory.

It’s a little difficult but I installed an extension success by compiling manually

Prepare

  • Install packages
brew install autoconf pcre
  • Download PHP source files for built-in PHP
xcode-select --install
  • Edit the /etc/php.ini, change the extension_dir to /usr/local/lib/php/extensions. The directory is writable. You should make the directory yourself.
  • Copy all extension files from /usr/lib/php/extensions to /usr/local/lib/php/extensions
  • Download the extension file and compile it
  • Edit /usr/bin/php-config, find line
extension_dir='/usr/local/lib/php/extensions/no-debug-non-zts-20090626'

and replace it with

extension_dir='/usr/local/lib/php/extensions'

Compile extension

For example, I compile swoole extension with these steps.

  • Download swoole-2.1.1.tgz from pecl.php.net
  • Unzip the file and compile the extension
tar xzvf swoole-2.1.1.tgz
cd swoole-2.1.1
phpize
./configure
make
make install

Leave a Reply Cancel reply

Your email address will not be published.

Comment

Name

Email

Website


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK