下载php源码包
http://www.php.net/downloads.php
安装php
可能出现的错误
出现错误: congigure error: xml2-config not found
解决办法:
1.执行命令:
2.查看是否成功:
出现错误: congigure error: Cannot find OpenSSL's <evp.h>
解决办法:
出现错误: configure: error: Please reinstall the BZip2 distribution
解决办法:
出现错误: configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/
解决办法:
出现错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:
出现错误:configure: error: Please reinstall readline - I cannot find readline.h
解决办法:
编译
可能出现的错误
编译PHP5.5 make 时出现错误
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
解决办法:
这是由于内存小于1G所导致.Disable fileinfo support 禁用 fileinfo
在./configure加上选项:
配置环境变量
添加 PHP 命令到环境变量
在末尾加入
要使改动立即生效执行
查看环境变量
查看php版本
PHP 5.5.13 (cli) (built: Jun 20 2014 11:11:26)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
配置启动php-fpm
启动php-fpm
配置nginx
修改nginx的配置文件(/etc/nginx/conf.d/default.conf)
检查nginx
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
则 已经配置正确
重启nginx
在web根目录下创建index.php
<?php echo phpinfo(); ?>
在浏览器中输入http://ip/index.php查看成功即可。
//注:根据自己的配置修改web根目录即可,如我的为/usr/share/nginx/html。
如果启动php-fpm出现错误: can not get uid for www,修改php-fpm.conf中user为nginx group为nginx