(1) swoole 环境搭建

PHP 环境搭建

PHP环境编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
yum -y  install  gcc  gcc-c++ libxml2-devel m4 autoconf pcre-devel make cmake bison openssl openssl-devel

wget http://mirrors.sohu.com/php/php-7.2.15.tar.gz

tar -zxvf php-7.2.15.tar.gz && cd php-7.2.15

./configure --prefix=/usr/local/php \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-libxml-dir=/usr \
--with-iconv-dir \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--enable-pcntl \
--enable-sockets \
--without-pear \
--with-gettext \
--enable-session

make && make install

添加 PHP 命令到环境变量

1
2
3
4
5
6
7
8
9
10
11
12
13
# vim /etc/profile

在末尾加入

PATH=$PATH:/usr/local/php/bin
export PATH

要使改动立即生效执行
# source /etc/profile

查看环境变量
# echo $PATH
# php -v

复制配置文件

1
2
3
4
5
6
[root@uiste php-7.2.15]# php -i | grep Configuration
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => (none)
Configuration
[root@uiste php-7.2.15]# mkdir -p /usr/local/php/etc/
[root@uiste php-7.2.15]# cp php.ini-development /usr/local/php/etc/php.ini

swoole安装

下载地址

swoole编译安装

1
2
3
4
5
6
7
wget http://pecl.php.net/get/swoole-4.2.13.tgz

tar -zxvf swoole-4.2.13.tgz && cd swoole-4.2.13

phpize

make && make install

配置php.ini

1
2
3
4
5
6
[root@uiste swoole-4.2.13]# vim /usr/local/php/etc/php.ini

extension=swoole.so

[root@uiste swoole-4.2.13]# php -m | grep swoole
swoole

通过php -m或phpinfo()来查看是否成功加载了swoole.so,如果没有可能是php.ini的路径不对,可以使用php –ini来定位到php.ini的绝对路径