Recommend Linux version: Ubuntu 16, CentOS 7 or greater
Swoole 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 Swoole 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 via Deb.Sury
#!/bin/bash # Install the Deb.Sury PHP Ubuntu PPA source sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update # Install a specific version of PHP sudo apt install php7.4
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 Swoole 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 Swoole compilation $ sudo apt install php-dev # Main requirements for Swoole 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 Swoole, 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
Then you can follow the installation documentation for using the Deb.Sury PPA to install Swoole.
Once you have all the general and linux dependencies you can then install Swoole on OS X systems.
After you have completed the prerequisites guide you can move onto installing Swoole