nginx配置
先在 cd /usr/local/nginx/conf 目录下找到 nginx.conf 文件
user www www;
worker_processes 8; error_log /home/wwwlogs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; pid /data/soft/nginx-1.8.1/logs/nginx.pid;
worker_rlimit_nofile 51200; events {
use epoll;
worker_connections 51200;
multi_accept on;
} 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 100M; 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 256k; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss/image/jpeg image/gif image/png;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\."; server_tokens off; 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 off; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; #tcp_nopush on; #keepalive_timeout 0; #gzip on; server {
listen 80 default_server;
server_name www.lnmp.org;
index index.html index.htm index.php;
root /home/wwwroot/default;
include enable-php.conf; error_page 404 /404.html; #charset koi8-r; #access_log logs/host.access.log main; location /nginx_status {
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/access.log access; } include vhost/*.conf;
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
是根据 http://www.linuxidc.com/Linux/2013-03/81738.htm 配置的
根据这个配置文件在相应目录建立文件夹(如 /home)
上传文件到相应文件夹
然后开始配置相应文件的配置文件,在 /usr/local/nginx/conf 目录下新建 vhost 文件夹 ,对应上传文件新建配置文件 .conf
如 home 下的 cigui.com.cn 文件夹对应 vhost 下的 cigui.com.cn.conf
server
{
listen 80;
server_name cigui.com.cn;
index index.html index.htm index.php;
root /home/wwwroot/cigui.com.cn; set $rule 0;
if ($request_uri ~* "^/(static|data|news|\.)/.*"){
set $rule '1';
} if ($rule ~ '0'){
rewrite ^/(.+)$ /index.php?/$1 last;
} #error_page 404 /404.html;
include enable-php.conf; location /nginx_status
{
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/cigui.com.cn.log access;
error_log /home/errorlogs/cigui.com.cn.log;
}
然后 /usr/local/nginx/sbin/nginx -s reload
完成配置,开始访问
具体问题具体分析解决!!!
nginx配置的更多相关文章
- nginx配置反向代理或跳转出现400问题处理记录
午休完上班后,同事说测试站点访问接口出现400 Bad Request Request Header Or Cookie Too Large提示,心想还好是测试服务器出现问题,影响不大,不过也赶紧上 ...
- Windos环境用Nginx配置反向代理和负载均衡
Windos环境用Nginx配置反向代理和负载均衡 引言:在前后端分离架构下,难免会遇到跨域问题.目前的解决方案大致有JSONP,反向代理,CORS这三种方式.JSONP兼容性良好,最大的缺点是只支持 ...
- Windows下Nginx配置SSL实现Https访问(包含证书生成)
Vincent.李 Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...
- Nginx 配置简述
不论是本地开发,还是远程到 Server 开发,还是给提供 demo 给人看效果,我们时常需要对 Nginx 做配置,Nginx 的配置项相当多,如果考虑性能配置起来会比较麻烦.不过,我们往往只是需要 ...
- Nginx配置详解
序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭借开源的力量,已经接近成熟与完善. Nginx功能丰富,可作为HTTP服务器,也 ...
- Nginx配置Https
1.申请证书: https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qc ...
- nginx配置为windows服务中的坑
网上搜索“nginx 配置为windows服务”,很容易搜索到使用windows server warpper来配置,于是按照网上的方法我从github上的链接下载了1.17版本,前面都很顺利,很容易 ...
- 【nginx配置】nginx做非80端口转发
一个场景 最近在使用PHP重写一个使用JAVA写的项目,因为需要查看之前的项目,所以要在本地搭建一个Tomcat来跑JAVA的项目.搭建成功后,因为Tomcat监听的端口是8080,因此,访问的URL ...
- Apache、nginx配置的网站127.0.0.1可以正常访问,内外网的ip地址无法访问,谁的锅?
最近做开发,发现一个比较尴尬的问题.因为我是一个web开发者,经常要用到Apache或者nginx等服务器软件,经过我测试发现,只要我打开了adsafe,我便不能通过ip地址访问我本地的网站了,比如我 ...
- nginx配置301重定向
1. 简介 301重定向可以传递权重,相比其他重定向,只有301是最正式的,不会被搜索引擎判断为作弊 2. 栗子 savokiss.com 301到 savokiss.me 3. nginx默认配置方 ...
随机推荐
- 【Data Cluster】真机环境下MySQL数据库集群搭建
真机环境下MySQL-Cluster搭建文档 摘要:本年伊始阶段,由于实验室对不同数据库性能测试需求,才出现MySQL集群搭建.购置主机,交换机,双绞线等一系列准备工作就绪,也就开始集群搭建.起初笔 ...
- Spring MVC学习
SpringMVC框架 转载请注明出处 目录 一:配置springMVC开发环境 1.1.配置文件的helloworld 1.2.基于注解的helloworld 二:@RequestMapping详解 ...
- ASP.NET Core 中文文档 第三章 原理(15)请求功能
作者:Steve Smith 翻译:谢炀(kiler398) 校对:姚阿勇(Dr.Yao).孟帅洋(书缘) 涉及到如何处理 HTTP 请求以及响应的独立 Web 服务器功能已经被分解成独立的接口,这些 ...
- 听歌识曲--用python实现一个音乐检索器
听歌识曲,顾名思义,用设备"听"歌曲,然后它要告诉你这是首什么歌.而且十之八九它还得把这首歌给你播放出来.这样的功能在QQ音乐等应用上早就出现了.我们今天来自己动手做一个自己的听歌 ...
- Asp.Net Core 项目实战之权限管理系统(3) 通过EntityFramework Core使用PostgreSQL
0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之 ...
- 翻译:使用 ASP.NET MVC 4, EF, Knockoutjs and Bootstrap 设计和开发站点 - 5 - 数据库设计
数据库方面我们需要的主要功能如下: 联系人有姓名和电子邮件地址. 联系人可以拥有多个地址. 联系人可以拥有多个电话. 为了实现目标,我们需要在数据库中创建下列表.表与表的关系如下图所示: 数据库的脚本 ...
- Yii 2.x 多主题 - 多语言 配置
语言:只要在原来模板的位置建立语言目录 多主题:要重新定义模板的根目录
- Servlet3.0的动态
动态的创建是为了简化配置文件的.对于我们创建的servlet,filter和listener后可以使用.这也是注解的另外一种替代方式. 动态的添加有两种,一种是基于ContextListener的,另 ...
- C++ STL简述
前言 最近要找工作,免不得要有一番笔试,今年好像突然就都流行在线笔试了,真是搞的我一塌糊涂.有的公司呢,不支持Python,Java我也不会,C有些数据结构又有些复杂,所以是时候把STL再看一遍了-不 ...
- Struts2入门(三)——数据类型转换
一.前言 笔者一直觉得,学习一个知识点,你首先要明白,这东西是什么?有什么用?这样你才能了解.好了,不说废话. 1.1.类型转换为何存在?什么是类型转换? 在MVC框架中,都是属于表示层解决方案,都需 ...