red5下nginx安装配置
http://zfl110.iteye.com/blog/1155149
原址:http://lqw.iteye.com/blog/652763
安装Nginx
1.首先安装pcre-8.02.tar 否则
执行完后会提示一个错误,说缺少PCRE library 这个是HTTP Rewrite 模块,也即是url静态化的包
可上传pcre-8.02.tar.gz,输入如下命令安装:
- tar xzvf pcre-8.02.tar
- ./configure
- make
- make install
2.执行如下命令解压nginx:
- tar xzvf nginx-0.8.35.tar.gz
3.编译安装nginx
- cd nginx-0.8.35
- ./configure --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module
#启动server状态页和https模块
- --with-http_stub_status_module 必须加上,不然报unknown directive "stub_status"
- make
- make install
4.nginx安装成功后的安装目录为/usr/local/nginx
在conf文件夹中新建proxy.conf,用于配置一些代理参数,内容如下:
- #!nginx (-)
- # proxy.conf
- proxy_redirect off;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr; #获取真实ip
- #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #获取代理者的真实ip
- client_max_body_size 10m;
- client_body_buffer_size 128k;
- proxy_connect_timeout 90;
- proxy_send_timeout 90;
- proxy_read_timeout 90;
- proxy_buffer_size 4k;
- proxy_buffers 4 32k;
- proxy_busy_buffers_size 64k;
- proxy_temp_file_write_size 64k;
编辑安装目录下conf文件夹中的nginx.conf,输入如下内容:
- #--------------------------------------------
- #运行nginx所在的用户名和用户组
- user nobody nobody;
- #启动进程数
- worker_processes 2;
- worker_cpu_affinity 0010 0001 ;
- #worker_cpu_affinity 0001 0100 1000 0010 0001 0100 1000 0010;
- #全局错误日志及PID文件
- error_log /usr/local/nginx/logs/nginx_error.log crit;
- pid /usr/local/nginx/logs/nginx.pid;
- worker_rlimit_nofile 65535;
- #工作模式及连接数上限
- events
- {
- use epoll;
- worker_connections 65535;
- }
- #设定http服务器,利用它的反向代理功能提供负载均衡支持
- http{
- include mime.types;
- default_type application/octet-stream;
- server_names_hash_bucket_size 128;
- #设定请求缓冲
- client_header_buffer_size 32k;
- large_client_header_buffers 4 32k;
- client_max_body_size 8m;
- sendfile on;
- tcp_nopush on;
- keepalive_timeout 60;
- tcp_nodelay on;
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 4 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
- #开启gzip模块
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.0;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css application/xml;
- gzip_vary on;
- #设定负载均衡列表
- upstream backend
- {
- #down 表示单前的server暂时不参与负载
- #weigth参数表示权值,权值越高被分配到的几率越大
- #server 192.168.3.69:80 weight=1;
- #max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
- #fail_timeout:max_fails次失败后,暂停的时间。
- #backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
- server 172.16.50.147:8081;
- server 172.16.50.147:8082;
- server 172.16.50.147:8083;
- server 172.16.50.147:8084;
- }
- #禁止通过ip访问站点
- #server{
- #server_name _;
- #return 404;
- #}
- #设定虚拟主机
- server {
- listen 80;
- server_name localhost;
- #对 / 所有做负载均衡 (本机nginx采用完全转发,所有请求都转发到后端的tomcat集群)
- location / {
- #设定网站的资源存放路径
- root /var/www ;
- #设定访问的默认首页地址
- index index.jsp index.htm index.html;
- #proxy_pass http://backend ;
- #保留用户真实信息
- include proxy.conf;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- #proxy_cache cache;
- #proxy_store on;
- proxy_temp_path /root/cache;
- proxy_cache_valid 200 302 24h;#200和302状态码保存1小时
- proxy_cache_valid 301 1d;#301状态码保存一天
- proxy_cache_valid any 10h;#其它的保存一分钟
- if ( !-f \$request_filename) {
- proxy_pass http://backend;
- }
- }
- #状态监控部分
- location /nginx {
- stub_status on;
- access_log on;
- auth_basic "NginxStatus";
- auth_basic_user_file /usr/local/nginx/htpasswd;
- #允许访问的ip allow 127.0.0.1;
- }
- #定义访问日志的写入格式
- log_format access '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" $http_x_forwarded_for';
- #设定访问日志的存放路径
- #access_log /usr/local/nginx/logs/access.log access;
- #设定access log
- access_log logs/access.log access;
- client_header_timeout 3m;
- client_body_timeout 3m;
- send_timeout 3m;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- #keepalive_timeout 65; (这个参数如果启用,会出现未知错误,因此暂时取消)
- }
- }
- #---------------------------------
5.修改/usr/local/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确:
- #/usr/local/nginx/sbin/nginx -t
如果屏幕显示以下两行信息,说明配置文件正确:
- the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
- the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully
如果提示unknown host,则可在服务器上执行:ping www.baidu.com如果也是同样提示unknown host则有两种可能:
a、服务器没有设置DNS服务器地址,查看/etc/resolv.conf下是否设置,若无则加上
b、防火墙拦截
备注:conf/htpasswd 文件的内容用 apache 提供的 htpasswd 工具来产生即可,如下:
- htpasswd -c /usr/local/nginx/htpasswd admin
输入密码:
6、启动nginx的命令
- #/usr/local/nginx/sbin/nginx
这时,输入以下命令查看Nginx主进程号:
- netstat -ntlp
- ps -ef | grep nginx
查看 Nginx 运行状态
输入地址 http://172.16.50.147/nginx/,输入验证帐号密码,即可看到类似如下内容:
- Active connections: 328
- server accepts handled requests
- 9309 8982 28890
- Reading: 1 Writing: 3 Waiting: 324
7、停止nginx的命令
- #/usr/local/nginx/sbin/nginx -s stop
8,修改配置文件不停止服务,而重新加载新配置文件
- kill -HUP PID
- #/usr/local/nginx/sbin/nginx -s reload
8.纪念日把整站变成黑白色调
在nginx.conf配置文件的http {...}大括号内增加以下两行:
- #sub_filter '</head>' '<style type="text/css">html {filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }</style></head>';
- #sub_filter_once on;
red5下nginx安装配置的更多相关文章
- VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)
首先启动Nginx 1. 相关浏览 两个 Tomcat 配置: VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...
- VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二)
准备工作 相关浏览: VMware Linux 下 Nginx 安装配置 (一) 1. 选在 /usr/local/ 下创建 softs 文件夹,通过 ftp 命令 把 apache-tomcat-7 ...
- linux下Nginx 安装配置
Nginx 安装 一.首先要安装 PCRE PCRE 作用是让 Ngnix 支持 Rewrite 功能. 1.下载 PCRE 安装包,下载地址: http://downloads.sourceforg ...
- CentOS 7服务器下Nginx安装配置
一.安装编译工具及库文件 $ yum -y install make zlib zlib-devel gcc gcc-c++ libtool openssl openssl-devel pcre pc ...
- VMware Linux 下 Nginx 安装配置 (一)
资源准备 1. pcre-8.34.tar.gz: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 2. zlib-1.2.8.tar.g ...
- centos7系统下nginx安装并配置开机自启动操作
准备工作 我的centos7系统是最小化安装的, 缺很多库, 首先安装必须的运行库 ? 1 2 3 4 5 6 7 8 9 10 11 yum install wget gcc gcc-c++ pcr ...
- linux系统下nginx安装目录和nginx.conf配置文件目录
linux系统下nginx安装目录和nginx.conf配置文件目录 1.查看nginx安装目录 输入命令 # ps -ef | grep nginx 返回结果包含安装目录 root 26 ...
- Nginx安装配置(转)
Nginx 安装配置 Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/ ...
- Linux下PHP安装配置MongoDB数据库连接扩展
Web服务器: IP地址:192.168.21.127 PHP安装路径:/usr/local/php 实现目的: 安装PHP的MongoDB数据库扩展,通过PHP程序连接MongoDB数据库 具体操作 ...
随机推荐
- BZOJ 1004 Cards(Burnside引理+DP)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1004 题意:三种颜色的扑克牌各有Sr,Sb,Sg张.给出m种置换.两种染色方案在某种置换 ...
- java中的clone
.clone 要实现cloneable接口: .深度clone和浅度clone .对象.clone() 1. Clone&Copy 假设现在有一个Employee对象,Employe ...
- UVa 12230 (期望) Crossing Rivers
题意: 从A到B两地相距D,之间有n段河,每段河有一条小船,船的位置以及方向随机分布,速度大小不变.每段河之间是陆地,而且在陆地上行走的速度为1.求从A到B的时间期望. 分析: 我们只要分析每段河的期 ...
- textContent、innerText的用法,在文档中插入纯文本
有时候需要查询纯文本形式的元素内容,或者在文档中插入纯文本.标准的方法是用Node的textContent属性来实现: var para = document.getElementsByTagName ...
- 微信分享自定义图片标题摘要-微信官方API
我们平时在使用微信内置浏览器打开网页想要分享给好友或者发到朋友圈的时候经常会遇到这样的问题, 别人的网页分享的时候是这样的: 而我们自己的网页分享后这这样的: 看到有人说不做任何设置,微信分享时会自动 ...
- nginx - conf.d vs sites-available
自己理解: conf.d - 扩展配置文件,用户配置文件 sites-available - 配置 虚拟主机(nginx支持多个虚拟主机,sites-enabled(存放 软链接,指向sites-av ...
- 【C#学习笔记】List容器使用
using System; using System.Collections.Generic; namespace ConsoleApplication { class Program { stati ...
- [shell]通过ping检测整个网段IP的网络状态脚本
要实现Ping一个网段的所有IP,并检测网络连接状态是否正常,很多方法都可以实现,下面简单介绍两种,如下:脚本1#!/bin/sh# Ping网段所有IP# 2012/02/05ip=1 #通过修改初 ...
- Chrome 实用调试技巧
Chrome 实用调试技巧 2016-07-23 如今Chrome浏览器无疑是最受前端青睐的工具,原因除了界面简洁.大量的应用插件,良好的代码规范支持.强大的V8解释器之外,还因为Chrome开发者工 ...
- HDU 5387 Clock
题意:给一个时间,求三个时针之间的夹角,分数表示. 解法:算算算.统一了一下分母. 代码: #include<stdio.h> #include<iostream> #incl ...