安装编译PHP7.X

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装编译PHP7.X相关的知识,希望对你有一定的参考价值。

安装此php版本前必须先安装另两篇Apche和myql安装环境,因为路径都是按照这两篇为基础的
https://blog.51cto.com/popli3/2357295
https://blog.51cto.com/popli3/2357211


安装PHP

  1. 安装yum环境(aliyun的yum环境)

    [[email protected] ~]#yum -y install bzip2-devel libmcrypt-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel

  2. 下载php7.3.2,去官网php或者直接在迅雷里下载(http://cn2.php.net/distributions/php-7.3.2.tar.gz)

  3. 解压php压缩包

    [[email protected] ~]# tar xf php-7.3.2.tar.gz

  4. 进入目录,设置编译环境

    [[email protected] ~]# cd php-7.3.2/ && ./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-apxs2=/usr/local/apache2.4/bin/apxs --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

  5. make编译

    [[email protected] php-7.3.2]#make && make install

  6. 复制模板文件

    [[email protected] php-7.3.2]# cp php.ini-production /usr/local/php/etc/php.ini

  7. 查看php模块是否加载

    [[email protected] php-7.3.2]# httpd -M
    ..............................
    autoindex_module (shared)
    dir_module (shared)
    alias_module (shared)
    php7_module (shared)

    1. 如果有php5和php7共存,注销一个,不然会有冲突

      [[email protected] php-7.3.2]# vi /usr/local/apache2.4/conf/httpd.conf
      ..................................
      #LoadModule rewrite_module modules/mod_rewrite.so
      #LoadModule php5_module modules/libphp5.so
      LoadModule php7_module modules/libphp7.so

以上是关于安装编译PHP7.X的主要内容,如果未能解决你的问题,请参考以下文章

centos8 测地卸载php5.6 与卸载php7

PHP7.X连接SQLSERVER数据库(CENTOS7)

PHP7.X连接SQLSERVER数据库(CENTOS7)

PHP7.X连接SQLSERVER数据库(CENTOS7)

如何编译安装PHP扩展

Docker 编译安装php7.3