Join 2,000+ others and never miss out on new tips, tutorials, and more.
pecl install openswoole-4.11.1
Recommend Linux version: Ubuntu 16, CentOS 7 or greater
OpenSwoole supports PHP 8.0 and PHP JIT
Before we start it is best to make sure your system has the latest updates and packages.
For Ubuntu/Debian this is easy, run the following commands:
#!/bin/bash sudo apt-get update && sudo apt-get upgrade
For CentOS and RedHat systems etc. check online guides on how to update your OS.
On Linux if you are installing OpenSwoole via PECL or the PHP PPA Repository (Deb.Sury) or compiling, you will need the following requirements/packages below.
You should have PHP installed first, refer to the PHP manual for this; in general though PHP can be installed by compiling PHP directly or via your Unix like package installation system, for example on Ubuntu/Debian:
PHP via Default Package on System
#!/bin/bash # Update your server $ sudo apt-get update && sudo apt-get upgrade # Install default PHP package $ sudo apt-get install php # Check installed version and info $ php -v
PHP Installation Complete
When we check our PHP install with
$ php -v you will see something like:
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
When using PHP PECL or cloning the OpenSwoole source to compile manually, you will need to meet the following requirements on Linux:
#!/bin/bash # Install the GCC Compiler sudo apt install gcc # Required for PECL installation and manual OpenSwoole compilation $ sudo apt install php-dev # Main requirements for OpenSwoole and useful packages $ sudo apt install openssl $ sudo apt install libssl-dev $ sudo apt install curl $ sudo apt install libcurl4-openssl-dev $ sudo apt install libpcre3-dev $ sudo apt install build-essential
If you plan on using CURL or MySQL with OpenSwoole, you need to have the compatible PHP extensions installed as well, check the example below for which extensions you may need.
You should change the PHP version to what you have installed.
#!/bin/bash # Recommended PHP Extensions sudo apt install php7.4-curl \ php7.4-json \ php7.4-mysql \ php7.4-common # Useful PHP Extensions sudo apt install php7.4-bcmath \ php7.4-gd \ php7.4-intl \ php7.4-mbstring \ php7.4-opcache \ php7.4-xml \ php7.4-zip
Once you have all the general and linux dependencies you can then install OpenSwoole on OS X systems.
After you have completed the prerequisites guide you can move onto installing OpenSwoole