美文网首页LNMP集合PHP实战
Centos7.2 编译安装PHP7

Centos7.2 编译安装PHP7

作者: hyperbolaa | 来源:发表于2017-06-16 16:38 被阅读998次

环境

    系统:Centos7.2 
    服务:Nginx 

1:下载PHP7.0.2的安装包解压,编译,安装:

    $ cd /usr/src/
    $ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz
    $ tar -xzxvf php-7.0.2.tar.gz
    $ cd php-7.0.2

1.1编译前检查

请检查是否安装了gcc ,没有的话执行yum install gcc
检查是否安装了libxml2 ,没有的话执行yum install libxml2
检查是否安装了libxml2-devel,没有的话执行yum install libxml2-devel
注:因为改为用nginx了,所以编译参数中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安装PHP前,请先安装apache。*

2:编译参数配置

'./configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--with-libdir=/lib/x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'

3:错误集合

报错 Cannot find OpenSSL's <evp.h>
  执行 yum install openssl openssl-devel

报错 Please reinstall the libcurl distribution
  执行 yum -y install curl-devel

错误 jpeglib.h not found
  执行 yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
  和执行 yum install libjpeg-devel

错误:checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution 这是bzip2软件包没有安装
  执行 yum install bzip2-devel.x86_64 -y

错误:configure: error: xpm.h not found.
  执行 yum install libXpm-devel

错误: Unable to locate gmp.h
  执行 yum install gmp-devel

错误:Unable to detect ICU prefix or /usr//bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works
  执行 yum install -y icu libicu libicu-devel

错误:mcrypt.h not found. Please reinstall libmcrypt.
  执行 yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

错误: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
  执行 yum install  postgresql-devel

错误: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
  执行  yum install libxslt-devel

4:编译

 make clean && make && make install

5:PHP配置

5.1安装完成后,我们要把源码包中的配置文件复制到PHP安装目录下,源码包中有两个配置 php.ini-development php.ini-production ,看名字就知道,一个是开发环境,一个是生产环境,我们这里就复制开发环境的

cp php.ini-development /usr/local/php/lib/php.ini

5.2另外还需要设置环境变量 :修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码

PATH=$PATH:/usr/local/php/bin
export PATH

5.3 然后执行生效命令

source /etc/profile

5.4查看PHP版本信息

php -v

6:配置PHP-fpm

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 /usr/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm

6.1 启动php-fpm:

/etc/init.d/php-fpm start

6.2 如果出现错误:ERROR: [pool www] cannot get uid for user 'www-data'

则新建www-data 用户组:
groupadd www-data
useradd -g www-data www-data

6.3 重启php-fpm

/etc/init.d/php-fpm restart

相关文章

  • 服务架设-CentOS7下编译安装 PHP7

    Centos7.2 编译安装PHP7 PHP7,编译安装: 环境:centos7.2 (注意:因为我用的ng...

  • PHP7 编译安装

    基准测试 - 可以对比所需版本性能 安装解压器 下载php7源码 解压php7源码 安装编译软件(必须) 安装编译...

  • Centos7.2 编译安装PHP7

    环境 1:下载PHP7.0.2的安装包解压,编译,安装: 1.1编译前检查 请检查是否安装了gcc ,没有的话执行...

  • php7.3.5配置swoole4

    一、PHP7源码安装和Swoole源码编译安装 1.1 PHP7源码安装 1.1.1 获取源码与安装 获取PHP7...

  • coturn穿透服务器搭建

    安装环境 阿里云CentOS7.2(64bit) 下载并安装libevent-2.0 下载编译安装coturn 查...

  • Centos6.5 编译安装 PHP 7.1.9

    PHP7 的时代到来了! 编译安装的好处 编译安装比yum 安装的好处是可以定制安装目录,想启用关闭哪些扩展都可以...

  • Centos7 编译安装PHP7

    Centos7 编译安装PHP7 编译安装的方式可以让组件等设置更加合理,但需要你对PHP的代码及各种配置非常的熟...

  • centos配置angular运行环境

    一、 编译源码安装 参考文章: 在centos7.2中配置angular运行环境详解 nodejs官网下载源码 官...

  • LNMP 环境配置 2017开春版集合

    目标: CentOS7.2 64位系统上部署好Nginx、PHP7、MariaDB 环境,支持https访问。 流...

  • Ubuntu 虚拟机初始化心得

    更新源 卸载不必要的软件 vmware chrome vscode PHP Ubuntu 编译安装 PHP7 ht...

网友评论

    本文标题:Centos7.2 编译安装PHP7

    本文链接:https://www.haomeiwen.com/subject/wgkyfxtx.html