首先下载php源码包并解压:

# wget http://cn2.php.net/get/php-7.0.9.tar.gz/from/this/mirror
# tar -xvf php-7.0..tar.gz
# cd php-7.0.

然后开始./configrue

./configure --enable-fpm --with-mysql

这里我只包含了 PHP-FPM 和 MySQL 支持的简单配置, 可以通过运行 ./configure --help 命令来获得完整的可用选项清单

configure过程中可能会出现的问题:

1. configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法:

# rpm -qa|grep libxml2
libxml2-python-2.9.-.el7_1..x86_64
libxml2-2.9.-.el7_1..x86_64

没有libxml2-devel

yum install libxml2-devel

问题解决!

configure完成后

+--------------------------------------------------------------------+
| License:                                   |
| This software is subject to the PHP License, available in this    |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement.    |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.    |
+--------------------------------------------------------------------+

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

继续安装

make && make install

经过“漫长”的等待后,编译完成

Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-/
Installing PHP CLI binary: /usr/local/bin/
Installing PHP CLI man page: /usr/local/php/man/man1/
Installing phpdbg binary: /usr/local/bin/
Installing phpdbg man page: /usr/local/php/man/man1/
Installing PHP CGI binary: /usr/local/bin/
Installing PHP CGI man page: /usr/local/php/man/man1/
Installing build environment: /usr/local/lib/php/build/
Installing header files: /usr/local/include/php/
Installing helper programs: /usr/local/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/man/man1/
page: phpize.
page: php-config.
Installing PEAR environment: /usr/local/lib/php/
[PEAR] Archive_Tar - installed: 1.4.
[PEAR] Console_Getopt - installed: 1.4.
[PEAR] Structures_Graph- installed: 1.1.
[PEAR] XML_Util - installed: 1.3.
[PEAR] PEAR - installed: 1.10.
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
/root/php-7.0./build/shtool install -c ext/phar/phar.phar /usr/local/bin
ln -s -f phar.phar /usr/local/bin/phar
Installing PDO headers: /usr/local/include/php/ext/pdo/

到这里,PHP已经安装成功了。

关于如何配置PHP,请参考PHP的官方文档。

Nginx+PHP: http://php.net/manual/zh/install.unix.nginx.php

Nginx和PHP配置完成之后,创建测试文件:

echo "<?php phpinfo(); ?>" >> /usr/local/nginx/html/index.php

访问http://localhost/index.php,如果可以将phpinfo打印到屏幕上,就证明 Nginx 和 PHP 配置正确。

如果您觉得阅读本文对您有帮助,欢迎转载本文,但是转载文章之后必须在文章页面明显位置保留此段声明,否则保留追究法律责任的权利。

作  者:blog.jpdou.top

原文链接:http://blog.jpdou.top/install-php7-from-source/

在CentOS7上源码安装php7--Install php7 from source on CentOS7的更多相关文章

  1. 国产化设备鲲鹏CentOS7上源码安装Python3.7

    具体编译过成与正常的Python源代码在x86平台上的过程无异,此篇随笔仅当用作复制黏贴的备忘录.不得不说在一个老旧系统上安装一个老旧的Python版本,从头编译一个Python还是一个较为稳健的选择 ...

  2. centos7上源码安装mysql5.7.11

    由于初学,安装这玩意搞了三天,其间各种报错难以解决,网上各种解答误导.最好的办法还是使用官方的英文文档,建议初学者一定要使用官方的文档,特别是下面两个页面作为初学者一定要细看: Installing ...

  3. 在CentOS7上源码安装OpenResty

    您必须将这些库perl 5.6.1+libreadlinelibpcrelibssl安装在您的电脑之中. 对于 Linux来说, 您需要确认使用 ldconfig 命令,让其在您的系统环境路径中能找到 ...

  4. CentOS7 实战源码安装mysql5.7.17数据库服务器

    CentOS7 实战源码安装mysql5.7.17数据库服务器 简介:实战演练mysql数据库服务器的搭建  mysql简介: mysql是一个开源的关系型数据库管理系统,现在是oracle公司旗下的 ...

  5. [原创]在Centos7.2上源码安装PHP、Nginx、Zentao禅道

    版本 操作系统:CentOS Linux release 7.2.1511 (Core) PHP:5.6.33 Nginx:1.12.2 MySQL:5.6.38(192.168.1.103的Wind ...

  6. CentOS7下源码安装mysql5.6

    目录 准备工作 运行环境 确认你的安装版本 下载mysql 安装mysql 准备安装环境 编译和安装 配置mysql 单实例配置      单实例配置方法          添加防火墙         ...

  7. CentOS7下源码安装5.6.23

    清理CentOS7下的MariaDB. [root@localhost ~]#rpm -qa | gremp mariadb     [root@localhost ~]# rpm -e --node ...

  8. centos7 中源码安装nginx

    使用nginx有一段时间了,还是有很多东西不懂的,在这里做一下自己学习过程中的一些整理,能使自己得到提升. 1.环境:centos7 1511  最小化安装 2.下载nginx,可以在系统中下载,也可 ...

  9. Centos6.6上源码安装Nodejs V4版本

    本来就是想在vps上装一个Ghost博客,这个博客依赖的是Nodejs,然后推荐的是V4版本.然后我就对着官网的步骤安装,发现根本没有Centos6 i386的资源了(64位的还是有的), 我只能在那 ...

随机推荐

  1. jQuery 验证 Validation

    jQuery Validation 目录 简介: Form validation made easy. Validate a simple comment form with inline rules ...

  2. IOS推流 搭建环境

    效果图 iTools有点卡, 但是推到服务器倒是很快的. 推流 前言 这篇blog是iOS视频直播初窥:<喵播APP>的一个补充. 因为之前传到github上的项目中没有集成视频的推流.有 ...

  3. emacs for OCaml

    (require 'cl) (require 'package) (add-to-list 'package-archives '("melpa" . "https:// ...

  4. STM in Clojure

    Transactional memory in Clojure is implemented using Multiversion Concurrency Control protocol http: ...

  5. 【机器学习】文本分类——朴素贝叶斯Bayes

    朴素贝叶斯主要用于文本分类.文本分类常见三大算法:KNN.朴素贝叶斯.支持向量机SVM. 一.贝叶斯定理 贝叶斯公式思想:利用已知值来估计未知概率.已知某条件概率,如何得到两个事件交换后的概率,也就是 ...

  6. state estimation for robotics-1

    概率论是探讨SLAM的一个重要的工具,概率密度函数的概率意义在于它能够描述一个随机变量位于任意区间的概率. p(x<=x<=x+dx)≍p(x).dx(由拉格朗日中值定理)

  7. Python模拟登录代码

    注:访问http://127.0.0.1:8080/user/6,总是会要求必须有登录权限,也就是,若未登录,访问该页面,会跳转到登陆页面. 全自动模拟登录 半自动模拟登录:

  8. ASP.NET MVC (Umbraco)中如何设置网站超时自动退出

    原文章请参考  https://edgewebware.com/2014/06/automatically-log-out-members-send-login-page-umbraco/ 在网站开发 ...

  9. 基于Laravel框架的一个简单易学的微信商城(新手必学)

    俗话说,麻雀虽小可五脏俱全呀! 今天分享的这个基于Laravel的小项目大概功能有这些: 1.实现会员登录.注册功能.数据双向验证功能.2.实现手机短信验证.邮件激活账号.邮件通知.3.ajax提交数 ...

  10. SQL 截取时间

    -- 获取系统时间 print getdate() -- 获取3天前的时间 print dateadd(day, -3 , getdate()) -- 获取3天后的时间 print dateadd(d ...