首先下载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/

最新文章

  1. 什么是OAuth授权?
  2. 深入研究C语言 第三篇
  3. ADO.NET防止字符串攻击方法
  4. paip.web数据绑定 下拉框的api设计 选择框 uapi python .net java swing jsf总结
  5. windows下捕获dump之Google breakpad_client的理解
  6. URAL1410. Crack
  7. android layoutparams应用指南(转)
  8. $.parseJSON 将json 对象转换为array
  9. 定制textField
  10. 动态代理 Proxy InvocationHandler
  11. oracle 中如何定位重要(消耗资源多)的SQL【转】
  12. apache 出现Index of /的页面解决
  13. Windows下如何创建低权限进程
  14. Python mysqldb模块
  15. bzoj 4868: [Shoi2017]期末考试
  16. 详解Ajax请求(三)——jQuery对Ajax的实现及serialize()函数对于表单域控件参数提交的使用技巧
  17. (数学) PTA 1005 继续(3n+1)猜想 (25 分)
  18. 出现Exception in thread &quot;main&quot; java.lang.UnsupportedClassVersionError: org/broadinstitute/gatk/engine/CommandLineGATK : Unsupported major.minor version 52.0问题解决方案
  19. 学习笔记1—python基础
  20. jQuery选择器遇上一些特殊字符

热门文章

  1. BZOJ3295:[CQOI2011]动态逆序对
  2. 洛谷P1092虫食算——深搜
  3. 你所不知道的html5与html中的那些事(五)——web图像
  4. php file_get_contents超时处理
  5. python的logging模块详细使用demo
  6. css3中变形处理
  7. eclipse中jquery.js文件有错误提示…
  8. 怎么将vim的剪切版设置成系统的剪切版
  9. ue4-C++中加载一个蓝图类(二)-C++中绑定Blueprint武器
  10. 51nod1241(连续上升子序列)