nginx支持LNMP

安装php-fpm

yum install php-fpm -y

使用/etc/php-fpm.d/www.conf配置文件默认配置即可

打开php配置:

vim /etc/nginx/conf.d/defaults
location ~ \.php$ {
root /usr/share/nginx/html;  
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
vim /etc/nginx/server.conf
location / {
root html;
index index.php index.html index.htm;  //支持index.php页面
}

修改fastcgi_parms

vim /etc/nginx/fastcgi_params
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
上面内容中添加如下一行:
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  

php支持mysql

# yum install php-mysql -y

安装mysql

# yum install mysql-server -y

测试页

<?php
$conn = mysql_connect('127.0.0.1','root','');
if ($conn)
echo succ;
else
echo failure;
mysql_close();
phpinfo();
?>

为动态内容fastcgi协议的集群设置缓存

http上下文中添加:
upstream upservers {
server 10.0.0.102 max_fails= fail_timeout=1s weight=;
server 10.0.0.103 max_fails= fail_timeout=1s weight=;
}
proxy_cache_path /cache/nginx/ levels=: keys_zone=mycache:32m;
fastcgi_cache_path /cache/fastcgi/ levels=: keys_zone=fcgicache:32m inactive=3m max_size=1g;
server.conf配置文件location中定义:
location ~ \.php$ {
fastcgi_cache fcgicache;
fastcgi_cache_valid 10m;
fastcgi_cache_valid 3m;
fastcgi_cache_valid any 1m;

root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}

其他参数介绍:

fastcgi_limit_rate: 限定从上游服务器收内容的速率

Syntax:    fastcgi_limit_rate rate;
Default:
fastcgi_limit_rate ;
Context: http, server, location
This directive appeared in version 1.7..

fastcgi_param: 向后端传递参数

Syntax:    fastcgi_param parameter value [if_not_empty];
Default: —
Context: http, server, location

fastcgi_store: 将内容存到磁盘上,不建议开启,如果要开启说明性能是下降的

Syntax:    fastcgi_store on | off | string;
Default:
fastcgi_store off;
Context: http, server, location
location /images/ {
root /data/www;
error_page 404 = /fetch$uri;
} location /fetch/ {
internal; fastcgi_pass backend:9000;
... fastcgi_store on;
fastcgi_store_access user:rw group:rw all:r;
fastcgi_temp_path /data/temp;  //不建议启用,应该加大内存空间buffer的大小 alias /data/www/;
}

关闭缓存

fastcgi_cache off;

nginx模块之ngx_http_fastcgi_module的更多相关文章

  1. nginx 模块介绍

    nginx模块在编译文件下的odjs目录下 cat 查看ngx_modules.c文件 可以看到一些基本extern模块 常用标准模块 1. 性能相关配置 worker_processes numbe ...

  2. nginx 模块简介

    nginx模块一般分为5类:核心模块.标准http模块.可选http模块.邮件服务模块.第三方模块. 其中核心模块和标准http模块在快速编译之后就包含在了nginx中. 主要看一下核心模块.标准ht ...

  3. Nginx模块详解

    Nginx模块介绍 核心模块:core module 标准模块: HTTP modules: Standard HTTP modules Optional HTTP modules Mail modu ...

  4. OpenResty / Nginx模块,Lua库和相关资源的列表

    OpenResty / Nginx模块,Lua库和相关资源的列表 什么是OpenResty OpenResty是一个成熟的网络平台,它集成了标准的Nginx核心,LuaJIT,许多精心编写的Lua库, ...

  5. 结合源码看nginx-1.4.0之nginx模块组织结构详解

    目录 0. 摘要 1. nginx模块组织结构 2. nginx模块数据结构 3. nginx模块初始化 4. 一个简单的http模块 5. 小结 6. 参考资料 0. 摘要 nginx有五大优点:模 ...

  6. 【转】Nginx模块开发入门

    转自: http://kb.cnblogs.com/page/98352/ 结论:对Nginx模块开发入门做了一个helloworld的示例,简单易懂.也有一定的深度.值得一看. Nginx模块开发入 ...

  7. Nginx模块开发入门

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  8. Nginx模块fastcgi_cache的几个注意点 转

    Nginx模块fastcgi_cache的几个注意点   去年年底,我对nginx的fastcgi_cache进行摸索使用.在我的测试过程中,发现一些wiki以及网络上没被提到的注意点,这里分享一下. ...

  9. 开发Nginx模块

    开发Nginx模块 前面的哪些话 关于Nginx模块开发的博客资料,网上很多,很多.但是,每篇博客都只提要点,无法"step by step"照着做,对于初次接触Nginx开发的同 ...

随机推荐

  1. Codeforces 1092 F Tree with Maximum Cost (换根 + dfs)

    题意: 给你一棵无根树,每个节点有个权值$a_i$,指定一个点u,定义$\displaystyle value = \sum^v a_i*dist(u,v)$,求value的最大值 n,ai<= ...

  2. HDU 1251 统计难题 (Trie树模板题)

    题目链接:点击打开链接 Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单 ...

  3. iOS - 一个简单的带标题的图标的实现

    代码不复杂,直接上代码: ImageViewButton.h // // ImageViewButton.h// // 带有图片.底部标题或者顶部的按钮 // // #import <UIKit ...

  4. 同步锁——ReentrantLock

    本博客系列是学习并发编程过程中的记录总结.由于文章比较多,写的时间也比较散,所以我整理了个目录贴(传送门),方便查阅. 并发编程系列博客传送门 Lock接口简介 在JUC包下面有一个java.util ...

  5. axios,vue-echarts, async, vue 图表数据处理; axios 跨域代理; 异步同步请求接口;生命周期函数

    1.vue-echarts 安装和组件引用 插件官网 https://github.com/ecomfe/vue-echarts 安装 npm install eacharts vue-echarts ...

  6. 10分钟快速搭建可用的springboot-web项目

    搭建步骤 工具准备 1. IntelliJ IDEA(开发工具,简称idea) 2. JDK1.8+ 3. MAVEN 4. mysql(数据库) 5. redis(session储存) 创建步骤 S ...

  7. 简单了解css3样式表写法和优先级

    css3和css有什么区别?首先css3是css(层叠样式表)技术的升级版本,而css是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言. ...

  8. Orleans[NET Core 3.1] 学习笔记(四)( 2 )获取Grain的方式

    简介 在这一节,我们将介绍如何在Silo和Client中获取Grain及调用Grain Grain获取方式 从Grain内部获取: //根据特定的Key值创建或获取指定的Grain IStudent ...

  9. 特殊符号unicode编码

    包括箭头类.基本形状类.货币类.数学类.音乐符号类.对错类.星星类.星座类.国际象棋类.扑克牌类.希腊字母.十字类.法律符号.标点符号,详情见以下网址:http://caibaojian.com/un ...

  10. node.remove()

    node.remove()方法是在DOM 4规范中实现的,由于糟糕的浏览器支持,不建议使用.应该使用removeChild方法,但是该方法必须要清楚父元素,通常的做法是:node.parentNode ...