Centos7.2 编译安装PHP7.0.2的步骤

 更新时间:2017年06月21日 09:48:13   作者:hyperbolaa  
本篇文章主要介绍了Centos7.2 编译安装PHP7.0.2的步骤。小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

环境

  1. 系统:Centos7.2 
  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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • Apache由http自动跳转到https的多种方法

    Apache由http自动跳转到https的多种方法

    本文主要和大家分享Apache http自动跳转到https的几种方法,非常不错,具有参考借鉴价值,需要的朋友参考下
    2018-02-02
  • ubuntu下迅雷极速版的安装与使用

    ubuntu下迅雷极速版的安装与使用

    Ubuntu是一个完全基于Linux的操作系统,它不但免费,而且有专业人员和业余爱好者共同为其提供技术支持。迅雷极速版的推出吸引了众多追求速度的网友关注。那么这篇文章我们就来学习下在ubuntu下迅雷极速版与QQ旋风的安装与使用,有需要的朋友们下面来一起看看吧。
    2016-10-10
  • shell脚本批量执行ping和telnet测试网络方式

    shell脚本批量执行ping和telnet测试网络方式

    文章介绍了如何通过创建shell脚本来简化本地网络测试任务,包括ping和telnet测试,文章详细描述了脚本的创建、编辑、赋予执行权限以及执行的步骤,并提供了具体的脚本示例
    2024-12-12
  • ubuntu服务器环境下安装python的方法

    ubuntu服务器环境下安装python的方法

    这篇文章主要介绍了ubuntu服务器环境下安装python的方法,简单分析了Ubuntu环境下安装Python的相关步骤、命令、与操作注意事项,需要的朋友可以参考下
    2018-03-03
  • Linux中使用crontab命令启用自定义定时任务实例

    Linux中使用crontab命令启用自定义定时任务实例

    本篇文章主要是介绍了Linux中使用crontab命令启用自定义定时任务实例,感兴趣的小伙伴们可以参考一下。
    2016-10-10
  • linux中install命令和cp命令的使用与区别

    linux中install命令和cp命令的使用与区别

    相信大家都知道linux中的命令Install和cp类似,都可以将文件/目录拷贝到指定的地点。下面这篇文章就详细介绍了linux中install命令和cp命令的介绍与区别。有需要的朋友们可以参考借鉴,下面来一起看看吧。
    2017-01-01
  • 解决yum安装报错Protected multilib versions的问题

    解决yum安装报错Protected multilib versions的问题

    今天小编就为大家分享一篇解决yum安装报错Protected multilib versions的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-07-07
  • Linux下查看binlog文件创建时间的命令

    Linux下查看binlog文件创建时间的命令

    这篇文章主要介绍了Linux下查看binlog文件创建时间的命令,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
    2019-05-05
  • Linux调试工具GDB使用简易教程

    Linux调试工具GDB使用简易教程

    这篇文章主要介绍了Linux调试工具GDB使用简易教程,小编觉得还是挺不错的,具有一定借鉴价值,需要的朋友可以参考下
    2018-01-01
  • CentOS 7.4下安装Oracle 11.2.0.4数据库的方法

    CentOS 7.4下安装Oracle 11.2.0.4数据库的方法

    本篇文章主要介绍了CentOS 7.4下安装Oracle 11.2.0.4数据库的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-12-12

最新评论