The Swoole extension is built as a standard PHP extension. Use phpize to generate build detection scripts,./configure to generate build configuration detection, make to compile, and make install to install.

Swoole official address www.swoole.com Swoole official document wiki.swoole.com

Installation preparation

Before installation, ensure that the following software has been installed in the system

  • Php-7.1 or later
  • Gcc-4.8 or later
  • make
  • autoconf

Installation steps

  1. Download the swoole source code

Go to GitHub to download the zip package :github.com/swoole/swoo…

  1. Compile and install from source
phpize
Copy the code
sudo ./configure
Copy the code
make && sudo make install
Copy the code
  1. Enable the extension

After a successful compilation installation, you need to enable the swoole extension by adding a line extension=swoole.so to php.ini

Problems encountered

The following error occurs when executing phpize:

phpize 
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  
Copy the code

The solution

Ln -s/Applications/Xcode. App/Contents/Developer/Platforms/MacOSX platform/Developer/SDKs/MacOSX10.12 SDK/usr/include /usr/includeCopy the code

Note: If you still fail, you should disable Rootless

Switch Rootless

Turning Rootless off and on is very simple, as follows:

Restart the Mac, press Command+R upon hearing the boot sound to enter recovery mode, go to the above menu utility and open Terminal (if there is no menu at the top, please continue to restart ^_^). Enter the following command:

  1. Close the Rootless
csrutil disable
Copy the code
  1. Open the Rootless
csrutil enable
Copy the code

After the command is executed, restart the PC to take effect.

The Swoole procedure and the problems encountered under the Mac are simple enough, looking forward to your attention 👍