nginx安装php和php-fpm
最近在学习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
最新文章
- [LeetCode] Scramble String 爬行字符串
- 扩展欧几里得算法(extgcd)
- IOS- 堆和栈 详解
- zabbix配fpmmm(mpm)数据传送不了问题解决
- 综合支撑【恶灵附身 Psycho Break】的世界观的概念艺术
- 马士兵 Servlet_JSP(2) JSP源代码)
- Test class should have exactly one public zero-argument constructor
- pythong下的unittest框架
- python3 爬虫---爬取豆瓣电影TOP250
- 备忘录之 —— .bashrc(IC工具篇)
- 如何卸载Centos自带jdk
- Spring之旅第三篇-Spring配置详解
- Java 解析Excel(xls、xlsx两种格式)
- spring boot controller设置 @Transactional 不回滚的解决办法
- Kivy 中文教程 实例入门 简易画板 (Simple Paint App):0. 项目简介 &; 成果展示
- bzoj4514 [Sdoi2016]数字配对(网络流)
- JSON.stringify和JSON.parse的使用
- oracle 复制表结构 复制表数据 sql 语句
- [POI2015]Odwiedziny
- 【转】inittab文件
热门文章
- Ci框架整合smarty模板引擎
- ANDROID_MARS学习笔记_S01原始版_022_MP3PLAYER002_本地及remote标签
- altium6.x中自动删除重复走线的位置
- QAbstractItemView为截断的项显示ToolTip(在eventFilter函数里覆盖QEvent::ToolTip事件)
- snapshot
- Visual Studio中的项目属性-->;生成-->;配置
- mapreduce源码分析总结
- php加速缓存Xcache的安装与配置
- HTTP请求中的缓存(cache)机制
- C# 深复制