Centos安装PHP7.0.9并启动PHP-FPM服务

一、编译并安装php环境

yum install -y postgresql-devel
rm -rf /usr/local/php
wget http://cn2.php.net/distributions/php-7.0.9.tar.gz -O php.tar.gz
tar zxvf php.tar.gz
cd php-7.0.9
./buildconf --force
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-bcmath=shared --with-pdo_sqlite=shared --with-gettext=shared --with-iconv=shared --enable-ftp=shared --with-sqlite=shared --with-sqlite3=shared --enable-mbstring=shared --enable-sockets=shared --enable-zip --enable-soap=shared --with-openssl --with-zlib --with-curl=shared --with-gd=shared --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mcrypt=shared --with-mhash=shared --enable-opcache --with-pgsql  --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --without-pear;
make && make install

二、清理与初始化配置文件

rm -rf /usr/local/php/etc/php.ini
rm -rf /usr/local/php/etc/php-fpm.conf
rm -rf /usr/local/php/etc/php-fpm.d/www.conf
rm -rf /etc/init.d/php-fpm

# 目录初始化
cp php.ini-development /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp -R ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 777 /etc/init.d/php-fpm

三、写入扩展到php配置文件

echo extension=bcmath.so >> /usr/local/php/etc/php.ini
echo extension=ftp.so >> /usr/local/php/etc/php.ini
echo extension=gettext.so >> /usr/local/php/etc/php.ini
echo extension=mbstring.so >> /usr/local/php/etc/php.ini
echo extension=mysqli.so >> /usr/local/php/etc/php.ini
echo extension=pdo_mysql.so >> /usr/local/php/etc/php.ini
echo extension=soap.so >> /usr/local/php/etc/php.ini
echo extension=sqlite3.so >> /usr/local/php/etc/php.ini
echo extension=curl.so >> /usr/local/php/etc/php.ini
echo extension=gd.so >> /usr/local/php/etc/php.ini
echo extension=iconv.so >> /usr/local/php/etc/php.ini
echo extension=mcrypt.so >> /usr/local/php/etc/php.ini
echo extension=sockets.so >> /usr/local/php/etc/php.ini

# 写入 opcache 缓存
echo zend_extension=opcache.so >> /usr/local/php/etc/php.ini
echo opcache.memory_consumption=128 >> /usr/local/php/etc/php.ini
echo opcache.interned_strings_buffer=8 >> /usr/local/php/etc/php.ini
echo opcache.max_accelerated_files=4000 >> /usr/local/php/etc/php.ini
echo opcache.revalidate_freq=60 >> /usr/local/php/etc/php.ini
echo opcache.fast_shutdown=1 >> /usr/local/php/etc/php.ini
echo opcache.enable_cli=1 >> /usr/local/php/etc/php.ini

四、启动 php-fpm 服务

chkconfig php-fpm on
service php-fpm start

原文链接:https://www.ctolog.com/linux/centos65-php709.html

标签:暂无标签