下载
cd /usr/local
wget https://www.php.net/distributions/php-7.2.34.tar.gz
解压安装
tar -zxvf php-7.2.34.tar.gz
cd php-7.2.34
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-zlib --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-bcmath --enable-shmop --enable-sysvsem --enable-gd --with-jpeg --with-freetype --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-opcache --enable-fpm --with-fpm-user=php --with-fpm-group=php --without-gdbm --enable-fast-install --disable-fileinfo --enable-maintainer-zts --enable-pthreads
make && make install
cd /usr/local/php-7.2.34/sapi/fpm/
cp init.d.php-fpm /usr/local/php/
cd /usr/local/php-7.2.34
cp php.ini-production /usr/local/php/etc/php.ini
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
启动
cd /usr/local/php
bash /usr/local/php/init.d.php-fpm start
vim ~/.bash_profile
source ~/.bash_profile
安装pthreads
cd /usr/local
下载pthreads
wget -c https://github.com/krakjoe/pthreads/archive/master.zip
或者
git clone https://github.com/krakjoe/pthread
unzip master.zip
cd /usr/local/pthreads-master
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
echo "extension=pthreads.so" >> /usr/local/php/etc/php.ini
安装完成相关扩展后重启php-fpm
如果报错:The fpm-fcgi SAPI is not supported by pthreads in Unknown on line 0
原因: CLI模式下,php会优先读取php-cli.ini,如果没找到会使用php.ini
解决办法:
1、注释php.ini 下的 pthreads 扩展 extension
2、cp php.ini php-cli.ini
3、打开php-cli.ini 下的 pthreads 扩展 extension
4、重新启动php-fpm