首頁 >php框架 >Swoole >swoole如何安裝(全紀錄分享)

swoole如何安裝(全紀錄分享)

藏色散人
藏色散人轉載
2022-01-30 05:00:314123瀏覽

今天swoole專欄帶大家分享swoole安裝的全紀錄,有需要的朋友可以看看,了解了解,有問題歡迎留言討論。

Ondřej Surý 的PHP PPA 為Ubuntu 16.04/14.04 提供了PHP7.2 版本,軟體來源安裝的PHP 預設以Unix Socket 的狀態運行在/run/php/php7.2-fpm.sock,比使用TCP 以localhost:9000 的方式效能更好。

1、安裝軟體來源拓展工具:

apt -y install software-properties-common apt-transport-https lsb-release ca-certificates

2、新增PHP PPA 來源並更新快取

add-apt-repository ppa:ondrej/php  & apt update

3、安裝php7.2及基礎相關拓展

#apt install php7.2-fpm php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-opcache php7.2-dev -y

4、查看目前PPA來源有哪些可供直接安裝的來源

apt-cache search php7.2
php-radis - radis client library for PHP
php-http - PECL HTTP module for PHP Extended HTTP Support
php-uploadprogress - file upload progress tracking extension for PHP
php-yaml - YAML-1.1 parser and emitter for PHP
php-mongodb - MongoDB driver for PHP
php-apcu - APC User Cache for PHP
php-imagick - Provides a wrapper to the ImageMagick library
php-ssh2 - Bindings for the libssh2 library
php-redis - PHP extension for interfacing with Redis
php-memcached - memcached extension module for PHP, uses libmemcached
php-apcu-bc - APCu Backwards Compatibility Module
php-rrd - PHP bindings to rrd tool system
php-uuid -##php-rrd - PHP bindings to rrd tool system
php-uuid -##php-densionension ##php-memcache - memcache extension module for PHP
php-zmq - ZeroMQ messaging bindings for PHP
php-igbinary - igbinary PHP serializer
php-msgpack -#php extension for interfacing with MessagePack##php -geoip - GeoIP module for PHP
php-tideways - Tideways PHP Profiler Extension
php-yac - YAC (Yet Another Cache) for PHP
php-mailparse - Email message manipulation for PHP
php- oauth - OAuth 1.0 consumer and provider extension
php-gnupg - PHP wrapper around the gpgme library
php-propro - propro module for PHP
php-raphf - raphf module for PHP##php-solv PHP extension for communicating with Apache Solr server
php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP
php-gearman - PHP wrapper to libgearman
php-phalcon - full-stack frame delivered as a C-extension
php-ds - PHP extension providing efficient data structures for PHP 7
php-sass - PHP bindings to libsass - fast, native Sass parsing in PHP
php-lua - PHP Embedded lua interpreter
libapache2-mod-php7.2 - server-side, HTML-embedded scripting language (Apache 2 module)
libphp7.2-embed - HTML-embedded scripting language (Embedded SAPI library)##17 .2-bcmath - Bcmath module for PHP
php7.2-bz2 - bzip2 module for PHP
php7.2-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.2 -cli - command-line interpreter for the PHP scripting language
php7.2-common - documentation, examples and common module for PHP
php7.2-curl - CURL module for PHP
php7.2-dba - DBA module for PHP
php7.2-dev - Files for PHP7.2 module development
php7.2-enchant - Enchant module for PHP
php7.2-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.2-gd - GD module for PHP
php7.2-gmp - GMP module for PHP
php7.2-imap - IMAP module for PHP
php7.2-interbase - Interbase module for PHP
php7.2-intl - Internationalisation module for PHP
php7.2-json - JSON module for PHP
php7.2-ldap - LDAP module for PHP
php7.2-mbstring - MBSTRING module for PHP
php7.2-mysql - MySQL module for PHP
php7.2-odbc - ODBC module for PHP
php7.2-opcache - Zend OpCache module for PHP
php7.2-pgsql - PostgreSQL module for PHP
php7.2-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.2-pspell - pspell module for PHP
php7.2-readline - readline module for PHP
php7.2-recode - recode module for PHP
php7.2-snmp - SNMP module for PHP
php7.2-soap - SOAP module for PHP
php7.2-sqlite3 - SQLite3 module for PHP
php7.2-sybase - Sybase module for PHP
php7.2-tidy - tidy module for PHP
php7.2-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.2-xmlrpc - XMLRPC-EPI module for PHP
php7.2-zip - Zip module for PHP
php7.2-xsl - XSL module for PHP (dummy)
php7.2 - server-side, HTML-embedded scripting language (metapackage)
php7.2-sodium - libsodium module for PHP

5、選擇安裝redis igbinary pear擴充
php7后每个扩展都是一个独立的ini文件
本次安装的php扩展都在/etc/php/7.2/mods-available下
apt install php-redis php-igbinary php-pear

ls /etc/php/7.2/mods-available

calendar.ini  fileinfo.ini  igbinary.ini  opcache.ini  opcache.ini readline.ini          
 sysvmsg.ini    xml.ini        zip.ini   ctype.ini     對       
 sysvsem.ini    xmlreader.ini
 curl.ini      gd.ini        mbstring.ini  pdo_mysql.ini  shmop.ini      
 sysvshm.ini    xmlrpc.ini
 dom.ini       gettext.ini   mysqli.ini    phar.ini       simplexml.ini  
 tokenizer.ini  xmlwriter.ini
 exif.ini      iconv.ini     mysqlnd.ini   posix.ini      sockets.ini    
 wddx.ini       xsl.ini

6、安装nghttp2库

apt install nghttp2 libnghttp2-dev

7、安装redis官方异步拓展hiredis,如报错需要增加系统gcc支持

git clone https://github.com/redis/hire...
 cd hiredis
make -j
 如果报错 尝试安装gcc
 apt install gcc
 重新编译
 make -j
 make install
 ldconfig

8、swoole拓展编译安装,不推荐使用pecl install swoole

pecl的安装方式没有编译http2与hiredis支持
gcc-4.4 或更高版本
make
autoconf
pcre (centos系统可以执行命令:yum install pcre-devel)
git clone https://gitee.com/swoole/swoo...
 cd swoole
 phpize
 ./configure  --enable-http2 --enable-async-redis
 make && make install

9、添加swoole扩展到php环境中

echo 'extension=swoole.so' >> /etc/php/7.2/mods-available/swoole.ini
cd /etc/php/7.2/cli/conf.d/ && ln -s ../../mods-available/swoole.ini 20-swoole.ini
cd /etc/php/7.2/fpm/conf.d/ && ln -s ../../mods-available/swoole.ini 20-swoole.ini

10、查看是否引用成功

php --ri swoole
swoole support => enabled
Version => 2.1.2-alpha
Author => tianfeng.han[email: mikan.tenny@gmail.com]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async redis client => enabled
async http/websocket client => enabled
openssl => enabled
http2 => enabled
Linux Native AIO => enabled
pcre => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

至此完整全部完成

更多swoole技术文章,请访问swoole教程栏目!

以上是swoole如何安裝(全紀錄分享)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:segmentfault.com。如有侵權,請聯絡admin@php.cn刪除