Centos安装php php-fpm 以及 配置nginx
下载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的更多相关文章
- CentOS安装Apache-2.4.10+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了各基础组件,并且配置了www用户和用户组,具体见<CentOS ...
- CentOS 7 学习(二) 配置Nginx反向代理
CentOS 7 学习(二) 配置Nginx反向代理 Nginx可以通过php-fpm来运行PHP程序,也可以转向apache,让apache调用php程序来运行. 不过对于Nginx来说,其反向代理 ...
- CentOS安装Apache-2.4.25+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了各基础组件,并且配置了www用户和用户组,具体见<CentOS ...
- CentOS安装Nginx-1.6.2+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了pcre等基础组件,具体见<CentOS安装LNMP环境的基础 ...
- CentOS安装Nginx-1.6.2+安全配置+性能配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了pcre等基础组件,具体见<CentOS安装LNMP环境的基础 ...
- CentOS安装MySQL-5.6.10+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装MySQL之前,请确保已经使用yum安装了各类基础组件,具体见<CentOS安装LNMP环境的基础组件& ...
- 【推荐】CentOS安装Tomcat-7.0.57+启动配置+安全配置+性能配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Tomcat之前,请确保已经安装了JDK-1.7环境,具体见<CentOS安装JDK-1.7>. ...
- 【推荐】CentOS安装vsftpd-3.0.2+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. FTP的登录一般有三种方式,分别是: 匿名用户形式:默认安装的情况下,系统只提供匿名用户访问,只需要输入用户anonymous/f ...
- 【推荐】CentOS安装vsftpd-3.0.3+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. FTP的登录一般有三种方式,分别是: 匿名用户形式:默认安装的情况下,系统只提供匿名用户访问,只需要输入用户anonymous/f ...
- centos安装mongodb 4.x及配置用户名密码(官方推荐的方式)
安装mongodb 先在本地用记事本做一个这样的文件(命名为:mongodb-org-4.0.repo): [mongodb-org-4.0] name=MongoDB Repository base ...
随机推荐
- PHP中的反射
PHP中的反射 PHP5 具有完整的反射 API,添加了对类.接口.函数.方法和扩展进行反向工程的能力. 此外,反射 API 提供了方法来取出函数.类和方法中的文档注释. 请注意部分内部 API 丢失 ...
- 在 Vue 结合 Axios 使用过程 中 post 方法,后台无法接受到数据问题
关于在 vue 中 使用 axios 相关 bug 首先,我们来看下 axios 的 github 传送门 axios 然后我们再介绍下 axios 的作者的 github 传送门 Matt 最后,我 ...
- EF架构~mysql中时间戳字段被认为是主键自增
回到目录 如果在mysql中添加了自增字段,用来维护行的版本,那么在EF中会有一个问题,会把它当成是数据表主键,当你的真正主键是自曾时,就会把默认值0拼到生成的SQL语句里,导致你的insert出错, ...
- EF架构~mysql数据库无法创建数据模型
回到目录 主要是通过vs2017+mysql.Data+Mysql.data.Entity+ef 来进行开始,当我们选择数据模型生成实体时,可以会出现以下问题: http:// 解决办法: 1.安装 ...
- 【Java基础】【01初识Java】
01.01_计算机基础知识(计算机概述)(了解) A:什么是计算机?计算机在生活中的应用举例 计算机(Computer)全称:电子计算机,俗称电脑.是一种能够按照程序运行,自动.高速处理海量数据的现代 ...
- Java——final关键字
前言 Java中的关键字final的含义通常为"这是无法改变的".下面将介绍final用于修饰数据.方法和类的这三种情况. final数据 许多编程语言都有某种方法,来向告诉编译器 ...
- mongoDB连接数据库
package mongod; import java.util.List; import java.util.ArrayList; import org.bson.types.*; import c ...
- 第一次AOP,附上使用DEMO,可用在简单生产环境了
demo代码如下 public class ConsoleTimeAttribute : ApectBaseAttribute { public override void Before(ApectC ...
- 【Mybatis】使用Mybatis-Generator自动生成entity、dao、mapping
使用过mybatis的应该都有用过Mybatis-Generator,本文主要介绍使用Mybatis-Generator来自动生成entity.dao.mapping文件. Mybatis-Gener ...
- Java设计模式——适配器模式(Adapter)
目的:把源类型适配为目标类型,以适应客户端(Client)的需求:此处我们把目标接口的调用方视为客户端 使用场景:需要对类型进行由源类型到目标类型转换的场景中 前置条件:已有客户端 //Client ...