安装php7.2.x
从PHP官网下载最新版PHP,然后编译安装
./configure --prefix=/opt/php72 --with-config-file-path=/opt/php72/etc/ --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv=/usr/local/lib --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache --enable-ftp --with-openssl-dir=/usr/include/openssl make && make install |
安装Swoole扩展
pecl安装
/opt/php72/bin/pecl install swoole
编译安装
wget http: //pecl.php.net/get/swoole-2.1.3.tgz tar zxvf swoole- 2.1 . 3 .tgz cd swoole- 2.1 . 3 /opt/php72/bin/phpize ./configure --with-php-config=/opt/php72/bin/php-config make && make install vim /opt/php72/etc/php.ini #添加extension = swoole.so php -m #查看是否支持swoole |
安装Redis扩展
wget http: //pecl.php.net/get/redis-3.1.6.tgz tar zxvf redis- 3.1 . 6 .tgz cd redis- 3.1 . 6 /opt/php72/bin/phpize ./configure --with-php-config=/opt/php72/bin/php-config make && make install vim /opt/php72/etc/php.ini #添加extension = redis.so php -m #查看是否支持redis |
安装inotify(可选) 用于修改代码后自动Reload Worker进程,检查本机inotify是否可用 php --ri inotify
/opt/php72/bin/pecl install inotify
安装mcrypt扩展(可选,7.2已弃用mcrypt,需自行安装扩展)
wget http://pecl.php.net/get/mcrypt-1.0.1.tgztar zxvf mcrypt-1.0.1.tgzcd mcrypt-1.0.1/opt/php72/bin/phpize./configure --with-php-config=/opt/php72/bin/php-configmake && sudo make install#添加extension = mcrypt.sophp -m#查看是否支持mcrypt如果出现 configure: error: mcrypt.h not found. Please reinstall libmcrypt. 错误提示安装mcrypt库即可 yum install libmcrypt libmcrypt-devel