下载php源码包

http://www.php.net/downloads.php

安装php

tar -xvf php-5.5..tar.bz2  

cd php-5.5.  

 ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear  

可能出现的错误

出现错误: congigure error: xml2-config not found

解决办法:

1.执行命令:

sudo yum install libxml2-devel  

2.查看是否成功:

find / -name "xml2-config" 

出现错误: congigure error: Cannot find OpenSSL's <evp.h>

解决办法:

yum install openssl openssl-devel
ln -s /usr/lib64/libssl.so /usr/lib/

出现错误: configure: error: Please reinstall the BZip2 distribution

解决办法:

yum install bzip2 bzip2-devel  

出现错误: configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/

解决办法:

yum -y install curl-devel
 

出现错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法:

sudo yum install libmcrypt libmcrypt-devel mcrypt mhash

出现错误:configure: error: Please reinstall readline - I cannot find readline.h

解决办法:

sudo yum install readline-devel

编译

make
make install

可能出现的错误

编译PHP5.5 make 时出现错误

make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

解决办法:
这是由于内存小于1G所导致.Disable fileinfo support 禁用 fileinfo

在./configure加上选项:

--disable-fileinfo      

配置环境变量

添加 PHP 命令到环境变量

vim /etc/profile 

在末尾加入

PATH=$PATH:/usr/local/php/bin
export PATH

要使改动立即生效执行

. /etc/profile 或 source /etc/profile

查看环境变量

echo $PATH   

查看php版本

php -v

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

cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf

启动php-fpm

sudo /usr/local/php/sbin/php-fpm  

配置nginx

修改nginx的配置文件(/etc/nginx/conf.d/default.conf)

location / {  

root web根目录;//在服务器中的目录  

index index.html index.htm index.php;  

}  

location ~ \.php$ {  

root html;  

fastcgi_pass 127.0.0.1:; //这个iP和端口对应php-fpm设置的端口  

fastcgi_index index.php;  

fastcgi_param SCRIPT_FILENAME web根目录$fastcgi_script_name;  

include fastcgi_params;  

}  

检查nginx

[root@server nginx]# ./sbin/nginx -t //检测配置文件是否正常
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

则 已经配置正确

 
 

重启nginx

/etc/init.d/nginx restart 

在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

Centos安装php php-fpm 以及 配置nginx的更多相关文章

  1. CentOS安装Apache-2.4.10+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了各基础组件,并且配置了www用户和用户组,具体见<CentOS ...

  2. CentOS 7 学习(二) 配置Nginx反向代理

    CentOS 7 学习(二) 配置Nginx反向代理 Nginx可以通过php-fpm来运行PHP程序,也可以转向apache,让apache调用php程序来运行. 不过对于Nginx来说,其反向代理 ...

  3. CentOS安装Apache-2.4.25+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了各基础组件,并且配置了www用户和用户组,具体见<CentOS ...

  4. CentOS安装Nginx-1.6.2+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了pcre等基础组件,具体见<CentOS安装LNMP环境的基础 ...

  5. CentOS安装Nginx-1.6.2+安全配置+性能配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了pcre等基础组件,具体见<CentOS安装LNMP环境的基础 ...

  6. CentOS安装MySQL-5.6.10+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装MySQL之前,请确保已经使用yum安装了各类基础组件,具体见<CentOS安装LNMP环境的基础组件& ...

  7. 【推荐】CentOS安装Tomcat-7.0.57+启动配置+安全配置+性能配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Tomcat之前,请确保已经安装了JDK-1.7环境,具体见<CentOS安装JDK-1.7>. ...

  8. 【推荐】CentOS安装vsftpd-3.0.2+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. FTP的登录一般有三种方式,分别是: 匿名用户形式:默认安装的情况下,系统只提供匿名用户访问,只需要输入用户anonymous/f ...

  9. 【推荐】CentOS安装vsftpd-3.0.3+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. FTP的登录一般有三种方式,分别是: 匿名用户形式:默认安装的情况下,系统只提供匿名用户访问,只需要输入用户anonymous/f ...

  10. centos安装mongodb 4.x及配置用户名密码(官方推荐的方式)

    安装mongodb 先在本地用记事本做一个这样的文件(命名为:mongodb-org-4.0.repo): [mongodb-org-4.0] name=MongoDB Repository base ...

随机推荐

  1. HashMap扩容全过程

      1.如果HashMap的大小超过了负载因子(load factor)定义的容量,怎么办? 默认的负载因子大小为0.75,也就是说,当一个map填满了75%的bucket时候,和其它集合类(如Arr ...

  2. 深入探究Lua的GC算法(上)-《Lua设计与实现》

    对于内存的管理,是程序在应用的时候的必需知识点,<Lua设计与实现>中对Lua语言的GC原理做了一个详细的讲解,云风的blog也对其进行了详尽的讲解Lua GC 的源码剖析 系列 给出作者 ...

  3. man帮助文档打印

    这里不讨论大家都知道的man重定向的一般常用方法(col处理方法)$ man find | col -b > man_fine.txt [跟着我的思路走]假如您像我一样,直接使用如下命令导出fi ...

  4. ASP.NET Core 2.1 : 十一. 如何在后台运行一个任务

    在大部分程序中一般都会需要用到后台任务, 比如定时更新缓存或更新某些状态.(ASP.NET Core 系列目录) 一.应用场景 以调用微信公众号的Api为例, 经常会用到access_token,官方 ...

  5. Mysql加锁过程详解(8)-理解innodb的锁(record,gap,Next-Key lock)

    Mysql加锁过程详解(1)-基本知识 Mysql加锁过程详解(2)-关于mysql 幻读理解 Mysql加锁过程详解(3)-关于mysql 幻读理解 Mysql加锁过程详解(4)-select fo ...

  6. JS引擎线程的执行过程的三个阶段(二)

    继续JS引擎线程的执行过程的三个阶段(一) 内容, 如下: 三. 执行阶段 1. 网页的线程 永远只有JS引擎线程在执行JS脚本程序,其他三个线程只负责将满足触发条件的处理函数推进事件队列,等待JS引 ...

  7. VisualStudio移动开发(C#、VB.NET)Smobiler开发平台——VoiceRecorder控件的使用方式.Net移动开发

    一.          样式一 我们要实现上图中的效果,需要如下的操作: 从工具栏上的“Smobiler Components”拖动一个VoiceRecorder控件和一个ImageButton控件到 ...

  8. VS Code调试.Net Core版Hello World

    安装C#插件 下载安装插件,地址:https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp 安装插件之后重新启动VS C ...

  9. 别的C#基础笔记

    1.方法名称             *  规范:每一个单词的首字母大写 2.方法的返回值 *  void:没有返回值.不能使用return来返回具体的值 ,但是可以使用return终止当前方法    ...

  10. ajaxFileUpload上传带参数,返回值改成json格式

    /*直接复制在自己的js文件中就能使用*/ jQuery.extend({ createUploadIframe: function (id, uri) { //create frame var fr ...