最近在学习nginx,看了好多帖子终于安装成功了。

经验,首先不要用yum安装,安装完以后根本找不到安装目录在哪里呀,然后安装失败以后会很不方便。

最终选择了自己编译安装。

看了好多帖子都不行,终于找到一个靠谱的呀,好详细。帖子地址http://www.cnblogs.com/zxpo/p/3798983.html

php-fpm打补丁

cd /usr/local/src

gzip -cd php-5.2.8-fpm-0.5.10.diff.gz  | patch -d php-5.2.8 -p1

下面是粘贴过来的帖子内容;

1、下载php源码包

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

2 、安装php

tar -xvf php-5.5.13.tar.bz2

cd php-5.5.13

./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.

解决办法:

执行命令: sudo yum install libxml2-devel

查看是否成功: 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

添加 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的配置文件(/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:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME web根目录$fastcgi_script_name;

include fastcgi_params;

}

重启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

nginx安装php和php-fpm的更多相关文章

  1. Nginx安装配置PHP(FastCGI)环境的教程

    这篇是Nginx安装配置PHP(FastCGI)环境的教程.Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用. 一.什么是 FastCGI F ...

  2. Linux中Nginx安装与配置详解

    转载自:http://www.linuxidc.com/Linux/2016-08/134110.htm Linux中Nginx安装与配置详解(CentOS-6.5:nginx-1.5.0). 1 N ...

  3. Linux环境Nginx安装与调试以及PHP安装

    linux版本:64位CentOS 6.4 Nginx版本:nginx1.8.0 php版本:php5.5.28 1.编译安装Nginx 官网:http://wiki.nginx.org/Instal ...

  4. centos下nginx安装和配置

    注:此文是根据前辈的博客和自己实际动手总结出来的,不喜勿喷 1.准备工作 Nginx的安装依赖于以下三个包,意思就是在安装Nginx之前首先必须安装一下的三个包,注意安装顺序如下: 1 SSL功能需要 ...

  5. zabbix 3.0.3 (nginx)安装过程中的问题排错记录

    特殊注明:安装zabbix 2.4.8和2.4.6遇到2个问题,如下:找了很多解决办法,实在无解,只能换版本,尝试换(2.2.2正常 | 3.0.3正常)都正常,最后决定换3.0.3 1.Error ...

  6. Nginx 安装以及反向代理配置(windows)

    安装 windows 下 Nginx 安装非常简单,下载地址 http://nginx.org/en/download.html. 选择红框这个,下载下来是个 zip 文件,解压.这时我们双击根目录的 ...

  7. nginx安装与配置

    一.在线安装 ubuntu 安装 sudo apt-get install nginx 安装后文件结构为: 配置文件:/etc/nginx ,并且每台虚拟主机已经安排在 /etc/nginx/site ...

  8. Windows下将nginx安装为服务运行

    今天看到nginx这个小服务器软件正式版更新到了1.4.2,想玩下它.这个服务器软件虽小,但功能强大,是开源软件,有着良好的性能,被很多个人.企业,甚至大型企业所使用! 由于是在Windows下,所以 ...

  9. windows下nginx安装、配置与使用(转载)

    目前国内各大门户网站已经部署了Nginx,如新浪.网易.腾讯等:国内几个重要的视频分享网站也部署了Nginx,如六房间.酷6等.新近发现Nginx 技术在国内日趋火热,越来越多的网站开始部署Nginx ...

  10. 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定

    阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...

随机推荐

  1. Spring+MyBatis实践—登录和权限控制

    1.实现用户登录功能: 通过session来实现用户登录功能.在用户登录时,将用户的相关信息放在HttpSession对象用,其中HttpSession对象可以通过HttpServletRequest ...

  2. Java 编程:如何提高性能?(简单总结篇)

    开发者在编程中除了要有编程规范,还要注意性能,在 Java 编程中有什么提高性能的好办法呢? 本文转自国内 ITOM 行业领军企业 OneAPM Cloud Insight(一款能够优雅监控多种操作系 ...

  3. 汇编语言第二版 程序在dos中执行情况.P86-87

    假设程序要被dos系统加载到sa:0000的内存中,在这个地址的内存开始会有256个字节的PSP程序,用于加载程序和dos系统的通信.ds中的地址为sa. 真正的程序会在这256个字节之后.所以真正程 ...

  4. MSSql2008打开企业管理器出错,具体显示提示无法识别的配置节 system.serviceModel。

    MSSql2008打开企业管理器出错详细信息: 标题: 已注册的服务器 ------------------------------   无法读取此系统上以前注册的服务器的列表.请在“已注册的服务器” ...

  5. IPv6 tutorial 4 IPv6 address syntax

    https://4sysops.com/archives/ipv6-tutorial-part-4-ipv6-address-syntax/ Now that you know about the n ...

  6. eclipse代码格式化

    今天想要改变Eclipse的代码颜色和背景等等,如果一项一项来,太麻烦了,于是从网上找了个epf文件,但是一开始不知道怎么弄,因为自己是个新手, 对于编译环境不太熟悉,后来找到方法,就是打开Eclip ...

  7. WCF中修改接口或步骤名称而不影响客户端程序

    WCF中修改接口或方法名称而不影响客户端程序 本篇接着"从Web Service和Remoting Service引出WCF服务"中有关WCF的部分. 运行宿主应用程序. 运行We ...

  8. JS中document.createElement()用法及注意事项

    今天处理了一个日期选择器的ie和ff的兼容问题,本来这种情况就很难找错误,找了好久才把错误定位到js中创建元素的方法document.createElement(),这个方法在ie下支持这样创建元素 ...

  9. 关于I/O的那点事

    转载请著名作者和地址http://www.cnblogs.com/scotth/p/3645489.html 1.关于 IO (fopen出现的错误 errorCode 183) 相关知识点: < ...

  10. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.2.2

    Show that the following statements are equivalent: (1). $A$ is positive. (2). $A=B^*B$ for some $B$. ...