Centos安装php php-fpm 以及 配置nginx

摘要:
˃在浏览器中输入http://ip/index.php查看成功。
下载php源码包

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

安装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

解决办法:

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:9000; //这个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》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇代码页实时监听移动端输入框的变化下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

CentOS 6.3下Samba服务器的安装与配置方法(图文详解)

这篇文章主要介绍了CentOS 6.3下Samba服务器的安装与配置方法(图文详解),需要的朋友可以参考下 一、简介Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件,而SMB是Server Message Block的缩写,即为服务器消息块 ,SMB主要是作为Microsoft的网络通讯协议,后来Samba将SMB通信协议应用到...

ubuntu上安装nginx+mysql+php5-fpm(PHP5

题外话:由于近段时间测试环境ssh链路质量不大好,经常短线。故我把整个安装过程放到screen里去执行,以防止断线中断了安装过程。执行screen -S install,这样断线后,只要再执行screen -r install 就可以恢复之前的安装界面。 1.安装mysql sudo apt-get install mysql-server mysql-c...

前后端分离的思考与实践(六)

原文出处: 淘宝UED - 筱谷    Nginx + Node.js + Java 的软件栈部署实践 起 关于前后端分享的思考,我们已经有五篇文章阐述思路与设计。本文介绍淘宝网收藏夹将 Node.js 引入传统技术栈的具体实践。 淘宝网线上应用的传统软件栈结构为 Nginx + Velocity + Java,即: 在这个体系中,Nginx 将请求转发给...

Linux下对nginx日志进行统计分析的常用命令

1.awk对nginx日志文件状态码的查询统计命令: No.1. cat /var/log/nginx/access.log-20210128 | awk '{print $9,$10}' | awk 'BEGIN{count[$1]=0}($2!=200){count[$1]+=1}END{for(i in count) print(i,count[i]...

如何在 Centos7 中修改yum源(三种方法)

(一)yum源概述 yum需要一个yum库,也就是yum源。默认情况下,CentOS就有一个yum源。在/etc/yum.repos.d/目录下有一些默认的配置文件(可以将这些文件移到/opt下,或者直接在yum.repos.d/下重命名)。 首先要找一个yum库(源),然后确保本地有一个客户端(yum这个命令就是客户端),由yum程序去连接服务器。连接的...

转:Nginx 日志文件切割

http://www.cnblogs.com/benio/archive/2010/10/13/1849935.html 偶然发现access.log有21G大,所以将其切割。 Nginx 是一个非常轻量的 Web 服务器,体积小、性能高、速度快等诸多优点。但不足的是也存在缺点,比如其产生的访问日志文件一直就是一个,不会自动地进行切割,如果访问量很大的话...