PHP7,编译安装:
环境:centos7.2    (注意:因为我用的nginx, 此配置参数没有考虑到apache,所以不合适需要用apache的朋友照搬过去运行,但是可以参考。
 
直接下载PHP7.0.2的安装包解压,编译,安装:
下载php7,并解压
$ 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
 
解压完后先不要编译,请检查是否安装了gcc ,没有的话执行yum install gcc
检查是否安装了libxml2 ,没有的话执行yum install libxml2
检查是否安装了libxml2-devel,没有的话执行yum install libxml2-devel
注:因为改为用nginx了,所以编译参数中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安装PHP前,请先安装apache。
 
编译参数配置
'./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'
 
出现报错 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
 
error: Unable to locate gmp.h
Fix: 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
 
配置的checking 结束后,执行:
 
make clean && make && make install
 
安装完成后,我们要把源码包中的配置文件复制到PHP安装目录下,源码包中有两个配置  php.ini-development  php.ini-production  ,看名字就知道,一个是开发环境,一个是生产环境,我们这里就复制开发环境的
cp php.ini-development /usr/local/php/lib/php.ini
 
另外还需要设置环境变量 :
修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码
PATH=$PATH:/usr/local/php/bin
export PATH
然后执行 命令 source /etc/profile
 
php -v 就可以看到PHP版本信息了。
 
 
此时还需要配置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
 
启动php-fpm:
/etc/init.d/php-fpm start
 
 
如果出现错误:ERROR: [pool www] cannot get uid for user 'www-data'
则新建www-data 用户组:
  1. groupadd www-data
  2. useradd -g www-data www-data
然后再启动php-fpm
 
然后安装nginx
yum install nginx

Centos7.2 编译安装PHP7的更多相关文章

  1. centos7.6编译安装php7.2.11及redis/memcached/rabbitmq/openssl/curl等常见扩展

    centos7.6编译安装php7..11及redis/memcached/rabbitmq/openssl/curl等常见扩展 获取Php的编译参数方法: [root@eus-api-cms-bac ...

  2. centos7下编译安装php-7.0.15(PHP-FPM)

    centos7下编译安装php-7.0.15(PHP-FPM) 一.下载php7源码包 http://php.net/downloads.php 如:php-7.0.15.tar.gz 二.安装所需依 ...

  3. Linux Centos7.2 编译安装PHP7.0.2

    操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/d ...

  4. centos7下编译安装php7.3

    一.下载php7.3的源码 https://www.php.net/downloads.php 下载php-7.3.4.tar.gz 二.安装gcc,gcc-c++,kernel-devel yum ...

  5. centos7.6编译安装php7.3

    刚开始搞环境装过集成,发现不好用,后来自己编译安装一些扩展啊设置的都很容易找到. 以前装过5.6.7.0发现不一样,最近出了7.3是php5速度的三倍,那有必要升级一下列. 由于之前安装过老版本,依赖 ...

  6. CentOS7.2编译安装PHP7.2.3之史上最详细步骤。

    首先,我们的CentOS版本信息如下: 开始我们的编译. 第一步: 将php安装包安装到/usr/src目录下. cd /usr/src && wget http://cn2.php. ...

  7. Centos7源码编译安装PHP7.2(生产环境)

    安装PHP依赖包,否则在编译的过程中可能会出现各种报错 # Centos 安装epel-release源并将系统包更新到最新版本 $ yum install epel-release-y $ yum ...

  8. centos7.6环境编译安装php-7.2.24修复最新 CVE-2019-11043 漏洞

    先编译安装php-7.2.24,然后编译安装扩展 主版本地址地址:https://www.php.net/distributions/php-7.2.24.tar.gz # 编译 php-7.2.24 ...

  9. Centos7 编译安装PHP7

    Centos7 编译安装PHP7 编译安装的方式可以让组件等设置更加合理,但需要你对PHP的代码及各种配置非常的熟悉,以下为大致的安装流程,大家可以参考 1.下载编译工具 yum groupinsta ...

随机推荐

  1. for循环与foreach

    注意点: for循环时,可以对集合进行操作,但foreach循环中,对集合进行操作会报错:                  for 循环可以获取下标 如下代码: package com.tt;imp ...

  2. photoshop基础教程视频-贺叶铭-传智播客-笔记

    界面构成 1.菜单栏 2.工具箱 3.工具属性栏 4.悬浮面板 5.画布 ctrl+n 新建对话框 (新建画布) 画布200*200大小,是指以毫米为单位,当不说单位,默认是毫米. 打开对话框:ctr ...

  3. Can't create handler inside thread that has not called Looper.prepare() 终极解决方法

    非主线程中出现 在报错的方法前加Looper.prepare(); 方法末尾加Looper.loop(); 很简单吧

  4. [转]异常:android.os.NetworkOnMainThreadException

    Android 4.1项目:使用新浪微博分享时报: android.os.NetworkOnMainThreadException 网上搜索后知道是因为版本问题,在4.0之后在主线程里面执行Http请 ...

  5. DWR整合之Servlet

    DWR 与 Servlet 有 2 个 Java 类你一般需要用在 DWR 中,是 webContext 和 WebContextFactory 在 DWR 1.x 它们在 uk.ltd.getahe ...

  6. 制作windows镜像

    下载包含windows驱动的iso: http://222.186.58.77/virtio-win-0.1-30.iso?fid=kF46uzxlPMrgvLDErP0ohhZYwAUASLoCAA ...

  7. [转] MMO即时战斗:地图角色同步管理和防作弊实现

    一.前言 无论是端游.页游.手游如果是采用了MMO即时战斗游戏模式,基本都会遇到同屏多角色实时移动.释放技能.战斗等场景,于是自然也需要实现如何管理同屏内各种角色的信息同步:例如角色的位置.以及角色身 ...

  8. Cannot find PHPUnit in include path phpstorm

    This is the way to do it without using composer, and using your global phpunit.Phpunit now comes wit ...

  9. Java正则表达式细节1

     Java中使用特定的字符类别比如 \d \s \w \d 匹配数字 \s 匹配空白字符 \w 匹配数字或者字符或者下划线[a-zA-Z0-9_] 比如使员正则的时候: 使用的是2个 斜杠 @Test ...

  10. SVN MERGE 和冲突

    摘要:最佳做法是避免冲突.冲突时,不要把branch merge到trunk. 先由最新版本的trunk得到branch,然后再修改文件,直接merge过去就行.这样不会有冲突.先用svn merge ...