最近在学习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. Android 风格化的 Toggle Buttons

    Android到默认UI比iOS到默认UI在美观程度上还是有一定到差距的,我们希望能够美化UI,并且替换掉系统默认的UI风格,使得程序在使用这些UI的时候都默认使用我们自定义到UI.本文以Toggle ...

  2. freshStartTail 第一次启动时 抛弃旧的日志

    freshStartTail [on/off] (requires v8.18.0+) Default: off This is used to tell rsyslog to seek to the ...

  3. jquery ajax cache的问题

    function test()        {            $.ajax({                type:'GET',                url:"tt. ...

  4. 【转】VC MFC 如何删除文件,目录,文件夹

    原文网址:http://shijuanfeng.blogbus.com/logs/100675115.html 第一种方法:定义一个文件类对象来操作CFile   TempFile;     Temp ...

  5. 发布网站,报Access to the path is denied的解决办法

    错误: Server Error in '/' Application.---------------------------------------------------------------- ...

  6. Android 所有颜色代码

    colors.xml <?xml version="1.0" encoding="utf-8" ?> <resources> <c ...

  7. PHP 201307 月最新手册chm 免费下载

    本次更新两个版本  php_manual_zh_notreview.chm (15MB 不带评论)     php_manual_zh_review.chm    (32MB 带评论)     制作方 ...

  8. Spring_Springmvc_mybatis一般配置

    web.xml配置 <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi=&quo ...

  9. JSP---JavaBean的使用-jsp:useBean标签相关

    JavaBean介绍: JavaBean其实就是一个遵循特定写法的java类,但是必须具有如下特点: 1.这个java类必须具有一个公开的无参构造函数 2.属性必须私有化,类必须公开 3.私有化的属性 ...

  10. 【原】Arrays.binarySearch() 的用法

    Arrays.binarySearch() 的用法 1.binarySearch(Object[] a, Object key) Searches the specified array for th ...