centos7编译php7.2

php版本7.2.6

备用安装包下载地址:php-7.2.6.tar.gz

一、更改yum源

安装阿里云yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

二、下载安装包并解压

wget http://cn2.php.net/distributions/php-7.2.6.tar.gz
tar zxf php-7.2.6.tar.gz -C /usr/local/src/

三、安装依赖

yum -y install libxml2 libxml2-devel bzip2 bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libc-client-devel libxslt-devel 

四、编译安装

1、切换目录

cd /usr/local/src/php-7.2.6

2、编译

./configure  \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-curl \
--with-gd \
--with-zlib \
--with-xmlrpc \
--with-openssl \
--with-gettext \
--with-mhash \
--with-libxml-dir=/usr \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-libdir=lib64 \
--with-pcre-regex \
--with-ldap-dir \
--with-imap  \
--with-imap-ssl  \
--with-kerberos  \
--with-xsl \
--with-bz2 \
--enable-xml \
--enable-fpm  \
--enable-ftp \
--enable-exif \
--enable-bcmath \
--enable-soap \
--enable-shmop \
--enable-sysvsem \
--enable-sockets \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-zip \
--enable-session \
--enable-ctype \
--enable-calendar \
--disable-rpath \
--enable-opcache \
--enable-gd-native-ttf \
--with-zlib-dir \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
&& make && make install

3、配置php配置文件

移动php配置文件的位置,并修改名称

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.conf

复制php.ini文件

cp /usr/local/src/php-7.2.6/php.ini-production /usr/local/php/etc/php.ini
4、启动脚本

复制php启动脚本到/etc/init.d/

cp /usr/local/src/php-7.2.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

添加执行权限,添加到启动项并设置开机自启动。

chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on

5、启动php-fpm

/etc/init.d/php-fpm start
© 版权声明
THE END
喜欢就支持一下吧
点赞1赞赏
分享
评论 抢沙发