PHP-7.1部署安装

部署环境:

  • Centos7.2.1511
  • Php7.2

部署安装:

  • 安装相关依赖服务
id www||useradd www  -M -s /sbin/nologin
yum install  epel-release  -y
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel \
libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype \
freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel \
libxslt libxslt-devel  gcc-c++ libicu-devel -y
  • 下载PHP源码包并编译安装
wget http://cn2.php.net/distributions/php-7.1.18.tar.gz
tar -xf php-7.1.18.tar.gz
cd php-7.1.18
./configure \
--prefix=/usr/local/php  \
--with-config-file-path=/usr/local/php/etc  \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-mysqlnd  \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-curl \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-gettext \
--with-libxml-dir=/usr \
--without-pear \
--disable-rpath \
--disable-fileinfo \
--enable-fpm \
--enable-ftp \
--enable-xml \
--with-xsl   \
--enable-intl \
--enable-zip \
--enable-soap \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--enable-maintainer-zts \
--enable-mbregex  \
--enable-mbstring \
--enable-opcache
make && make install

  • 拷贝相关配置并启动
cp php.ini-production /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 sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
/etc/init.d/php-fpm start

PHP参数详解

–prefix=/usr/local/php:指定PHP服务安装路径
–with-config-file-path=/usr/local/php/etc:指定PHP配置文件路径
–with-fpm-user=www:指定系统用户
–with-fpm-group=www:指定系统组
–enable-mysqlnd:启用Mysql Native驱动
–with-mysqli=mysqlnd:指定Mysql Native驱动
–with-pdo-mysql=mysqlnd:指定Mysql Native驱动
–with-iconv-dir:添加iconv模块
–with-freetype-dir
–with-jpeg-dir
–with-png-dir
–with-zlib
–with-curl
–with-mcrypt
–with-gd
–with-openssl
–with-mhash
–with-xmlrpc
–with-gettext
–with-libxml-dir=/usr
–without-pear
–disable-rpath
–disable-fileinfo
–enable-fpm
–enable-ftp
–enable-xml
–with-xsl
–enable-intl
–enable-zip
–enable-soap
–enable-bcmath
–enable-shmop
–enable-sysvsem
–enable-inline-optimization
–enable-gd-native-ttf
–enable-pcntl
–enable-sockets
–enable-maintainer-zts
–enable-mbregex
–enable-mbstring
–enable-opcache:启用PHP缓存-opcache

  • 将PHP添加到环境变量
cat > /etc/profile.d/PHP-BIN.sh <<EOF
export PHP_BIN=/usr/local/php/bin
export PATH=\${PATH}:\${PHP_BIN}
EOF
source /etc/profile.d/PHP-BIN.sh
点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注