Linux(CentOS6.5)下修改Nginx初始化配置
本文地址http://comexchan.cnblogs.com/,作者Comex Chan,尊重知识产权,转载请注明出处,谢谢!
首先备份相关文件:
cp /comexHome/nginx/conf/nginx.conf /comexHome/nginx/conf/nginx.conf.bak.comex
cp /comexHome/nginx/conf/mime_types /comexHome/nginx/conf/mime_types.bak.comex
cp /comexHome/nginx/conf/fastcgi_conf /comexHome/nginx/conf/fastcgi_conf.bak.comex
cp /comexHome/nginx/conf/proxy_conf /comexHome/nginx/conf/proxy_conf.bak.comex
然后替换默认配置
cat << EOF >/comexHome/nginx/conf/nginx.conf
##################################################
# Desc: /comexHome/nginx/conf/nginx.conf
# Modified from Nginx Conf Sample By Comex Chan
# http://comexchan.cnblogs.com/
# ------------------------------------------------
# Ver. Date ModifiedBy Tips
# 1.0 2016-08-28 Comex Chan Init Version
# ------------------------------------------------
################################################## user comex comexgroup; ## Default: nobody
worker_processes 8; ## Default: 1.The same with the CPU cores
error_log /comexLog/nginx/error.log;
pid /comexHome/nginx/nginx.pid;
worker_rlimit_nofile 8192; events {
worker_connections 4096; ## Default: 1024
} http {
include /comexHome/nginx/conf/mime_types;
include /comexHome/nginx/conf/proxy_conf;
include /comexHome/nginx/conf/fastcgi_conf;
index index.html index.htm index.php; default_type application/octet-stream;
log_format main ' - [] '
'"" "" '
'"" ""';
access_log /comexLog/nginx/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts server { # php/fastcgi
listen 10080;
server_name domain1.com www.domain1.com;
access_log /comexLog/nginx/domain1.access.log main;
root html; location ~ \.php\$ {
fastcgi_pass 127.0.0.1:1025;
}
} server { # simple reverse-proxy
listen 80;
server_name domain2.com www.domain2.com;
access_log /comexLog/nginx/domain2.access.log main; # serve static files
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /var/www/virtual/big.server.com/htdocs;
expires 30d;
} # pass requests for dynamic content to rails/turbogears/zope, et al
location / {
proxy_pass http://127.0.0.1:8080;
}
} upstream big_server_com {
server 127.0.0.3:8000 weight=5;
server 127.0.0.3:8001 weight=5;
server 192.168.0.1:8000;
server 192.168.0.1:8001;
} server { # simple load balancing
listen 80;
server_name big.server.com;
access_log /comexLog/nginx/big.server.access.log main; location / {
proxy_pass http://big_server_com;
}
}
} #################################
# TCP Proxy Conf
#################################
stream {
upstream backend {
server 127.0.0.1:12345 weight=5;
#server backend1.example.com:12345 weight=5;
#server 127.0.0.1:12345 max_fails=3 fail_timeout=30s;
#server unix:/tmp/backend3;
} upstream dns {
server 127.0.0.1:53535;
#server 192.168.0.1:53535;
#server dns.example.com:53;
} server {
listen 12345;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass backend;
} server {
listen 127.0.0.1:53 udp;
proxy_responses 1;
proxy_timeout 20s;
proxy_pass dns;
} server {
listen 127.0.0.1:12345;
proxy_pass unix:/tmp/stream.socket;
}
}
EOF cat << EOF >/comexHome/nginx/conf/mime_types
##################################################
# Desc: /comexHome/nginx/conf/mime_types
# Modified from Nginx Conf Sample By Comex Chan
# http://comexchan.cnblogs.com/
# ------------------------------------------------
# Ver. Date ModifiedBy Tips
# 1.0 2016-08-28 Comex Chan Init Version
# ------------------------------------------------
##################################################
types {
text/html html htm shtml;
text/css css;
text/xml xml rss;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
text/plain txt;
text/x-component htc;
text/mathml mml;
image/png png;
image/x-icon ico;
image/x-jng jng;
image/vnd.wap.wbmp wbmp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/pdf pdf;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;
application/octet-stream deb;
application/octet-stream bin exe dll;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/mpeg mp3;
audio/x-realaudio ra;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-msvideo avi;
video/x-ms-wmv wmv;
video/x-ms-asf asx asf;
video/x-mng mng;
}
EOF cat << EOF >/comexHome/nginx/conf/fastcgi_conf
##################################################
# Desc: /comexHome/nginx/conf/fastcgi_conf
# Modified from Nginx Conf Sample By Comex Chan
# http://comexchan.cnblogs.com/
# ------------------------------------------------
# Ver. Date ModifiedBy Tips
# 1.0 2016-08-28 Comex Chan Init Version
# ------------------------------------------------
##################################################
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
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_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 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; fastcgi_index index.php; fastcgi_param REDIRECT_STATUS 200;
EOF cat << EOF >/comexHome/nginx/conf/proxy_conf
##################################################
# Desc: /comexHome/nginx/conf/proxy_conf
# Modified from Nginx Conf Sample By Comex Chan
# http://comexchan.cnblogs.com/
# ------------------------------------------------
# Ver. Date ModifiedBy Tips
# 1.0 2016-08-28 Comex Chan Init Version
# ------------------------------------------------
##################################################
proxy_redirect off;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
EOF
最后测试配置文件是否ok
/comexHome/nginx/sbin/nginx –t
下图即为ok:
Linux(CentOS6.5)下修改Nginx初始化配置的更多相关文章
- Linux - CentOS6.5服务器搭建与初始化配置详解(下)
传送带:Linux - CentOS6.5服务器搭建与初始化配置详解(上) 继续接着上面的安装,安装完后会出现下面界面 点击reboot重启 重启后可以看到下面的tty终端界面 因为这就是最小化安装 ...
- Linux - CentOS6.5服务器搭建与初始化配置详解(上)
1.新建一个虚拟机 选择典型 单机下一步 p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm 0cm 0.0001pt; text-align: ...
- CentOS6.5下Tomcat7 Nginx Redis配置步骤
所有配置均在一台机器上完成,部署拓扑信息如下: 注意:由于Redis配置对jar包和tomcat版本比较严格,请务必使用tomcat7和本文中提供的jar包.下载地址: http://pan.baid ...
- Linux下的Nginx的配置+Tomcat启动
Linux下的Nginx的配置 首次如果你只仅主机模式,那么请你切换到桥接模式或者net模式. 1.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc ...
- Linux(CentOS6.5)下编译安装Nginx官方最新稳定版(nginx-1.10.0)
注:此文已经更新为新版:http://comexchan.cnblogs.com/p/5815753.html ,请直接查看新版,谢谢! 本文地址http://comexchan.cnblogs.co ...
- Linux centos7环境下安装Nginx
Linux centos7环境下安装Nginx的步骤详解 1. 首先到Nginx官网下载Nginx安装包 http://nginx.org/download/nginx-1.5.9.tar.gz ...
- CentOS 下 安装 nginx 执行配置命令 ./configure 报错
CentOS 下 安装 nginx 执行配置命令 ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx 时提示以下错误: checkin ...
- Linux/CentOS环境下如何安装和配置PhantomJS工作环境
PhantomJS 是一个基于WebKit的服务器端 JavaScript API.它全面支持web而不需浏览器支持,其快速,原生支持各种Web标准: DOM 处理, CSS 选择器, JSON, C ...
- Linux下安装Nginx并配置一个图片服务器
首先安装nginx安装环境 nginx是C语言开发,建议在linux上运行,本教程使用Centos6.5作为安装环境. gcc 安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没 ...
随机推荐
- js脚本根据身份证号获取性别、年龄、家庭地址、生日
做项目测试时需要根据身份证号获取其信息,也不想调接口,就自己在本地通过收集资料整合了一个
- Etcd全套安装教程
一.安装 1.1 二进制安装 从这里下载: etcd-v3.2.11-linux-amd64.tar.gz 下载包后解压即可运行: # 解压 tar zxvf etcd-v3.2.11-linux-a ...
- C++反汇编第五讲,认识多重继承,菱形继承的内存结构,以及反汇编中的表现形式.
C++反汇编第五讲,认识多重继承,菱形继承的内存结构,以及反汇编中的表现形式. 目录: 1.多重继承在内存中的表现形式 多重继承在汇编中的表现形式 2.菱形继承 普通的菱形继承 虚继承 汇编中的表现形 ...
- java 接口测试,使用excel做数据驱动(二)
承接上篇. 改变我们的测试驱动方式,灵活设置测试用例. 数据驱动测试 数据驱动测试的核心是: 测试数据与测试脚本分离,实现测试脚本参数化, 提高测试脚本的可重用性.在自动化功能测试中如果灵活使用数据源 ...
- codeforge免费下载账号 积分账号 共享账号
codeforge网站下载代码很好,没有积分怎么办?那么多好的matlab代码,matlab程序,C,JAVA等等,都要充值啊!!! 请用下面共享的codeforge账号密码========> ...
- Java VS .NET:Java与.NET的特点对比
一.前言 为什么要写Java跟.NET对比? .NET出生之后就带着Java的影子.从模仿到创新,.NET平台也越来越成熟.他们不同的支持者也经常因为孰弱孰强的问题争论不休.但是本文并不是为了一分高下 ...
- dict.get()和dict['key']的区别
a ={'name':'xxxx'} 1.a.get('gender') :如果不存在则返回一个默认值,如果设置了则返回默认的值,没有设置就返回None 2.a['gender'] :只能获取存在的值 ...
- python爬虫(四)_urllib2库的基本使用
本篇我们将开始学习如何进行网页抓取,更多内容请参考:python学习指南 urllib2库的基本使用 所谓网页抓取,就是把URL地址中指定的网络资源从网络流中读取出来,保存到本地.在Python中有很 ...
- less新手入门(二) Mixin 混合、带参数的Mixin
四.mixin 混合 "mix - in"属性来自现有的样式!! 你可以在类选择器和id选择器中使用mixin, .a,#b{ color: rebeccapurple; } . ...
- AndroidStudio下gradle的入门介绍与使用
參考: 网易云加密:http://apk.aq.163.com 网易云捕:http://crash.163.com 1 Groovy Groovy 是没有类型的 Java 代码 ,语法更简洁.形式有点 ...