nginx(一)之默认配置文件
首先是nginx.conf
vim /etc/nginx/nginx.conf
user nginx; // 设置nginx服务的系统使用用户
worker_processes 1; // 工作进程数
error_log /var/log/nginx/error.log warn; // nginx的错误日志
pid /var/run/nginx.pid; // nginx服务启动时候pid
events { // 事件模块,nginx优势利用epoll内核模型,在这里可以配置使用哪个内核模型
worker_connections 1024; // 每个进程允许最大连接数 ,还有个use是工作进程数
}
http {
include /etc/nginx/mime.types; //设置contentType
default_type application/octet-stream;
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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65; // 服务端超时时间
#gzip on;
include /etc/nginx/conf.d/*.conf; // 读到这个地方是加载另一个默认配置配置文件default.conf
}
default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm; // 默认加载根路径文件
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
"/etc/nginx/conf.d/default.conf" 45L, 1093C

http可以包含多个http服务,一个server配置一个独立的站点。一个http可以有多个server,一个server可以有多个location匹配资源路径
nginx(一)之默认配置文件的更多相关文章
- nginx新建nginx_fzjh.conf文件,不使用默认配置文件
worker_processes 4; events{ worker_connections 1024; } http{ server { listen 80; server_name myserve ...
- nginx默认配置文件解释
nginx默认配置文件 nginx.conf 介绍: 全局配置 user nginx; 设置nginx服务的系统使用用户 worker_processes 1; 工作进程数(建议和CPU核心数保持 ...
- 更改 Nginx 服务的默认用户
为什么要更改 Nginx 服务的默认用户:就像更改 ssh 的默认 22 端口一样,增加安全性,Nginx 服务的默认用户是 nobody ,我们更改为 nginx 1.添加 nginx 用户 use ...
- 【转载】Docker 安装 Nginx 并个性化挂载配置文件 nginx.conf
首先,系统(3.8以上内核的linux)中安装好 Docker 这个运用程序.由于网络原因,我们下载一个Docker官方的镜像需要很长的时间,甚至下载失败.为此,阿里云容器镜像服务提供了官方的镜像站点 ...
- Nginx安装、默认虚拟主机、Nginx用户认证和域名重定向
6月7日任务 12.6 Nginx安装12.7 默认虚拟主机12.8 Nginx用户认证12.9 Nginx域名重定向 扩展nginx.conf 配置详解 http://www.ha97.com/51 ...
- Nginx优化之基本安全优化 (隐藏Nginx软件版本号信息,更改源码隐藏Nginx软件名及版本号,更改Nginx服务的默认用户)
一,隐藏Nginx软件版本号信息 查看版本号 curl -I 192.168.0.220 HTTP/1.1 200 OK Server: nginx/1.6.2 #这里清晰的暴露了Web版本号(1.6 ...
- Linux centosVMware Nginx安装、 默认虚拟主机、Nginx用户认证、Nginx域名重定向
一. Nginx安装 cd /usr/local/src wget http://nginx.org/download/nginx-1.12.1.tar.gz 版本在http://nginx.org/ ...
- struts2默认配置文件 struts-default.xml
注:用的struts2的版本是2.1.6 strtus2的默认配置文件 struts-default.xml ,其中的默认的拦截器,包括其中的拦截器栈. 因为struts2的配置文件struts.xm ...
- nginx转发会 默认忽略 headers 中name带”_”的
昨天遇到一个很蛋疼的问题,在提供的一个 http api中,有定义了一个"X_AUTH_TOKEN"自定义head,可是请求这个api时带上"X_AUTH_TOKEN&q ...
- Windows Redis默认配置文件,Redis配置不生效解决方案
Windows Redis默认配置文件,Redis配置不生效解决方案, Windows Redis自启动配置不生效解决方案,Windows Redis增加自动启动服务 >>>> ...
随机推荐
- [C++]2-2 韩信点兵
/* 韩信点兵 相传韩信才智过人,从不直接清点自己军队的人数,只要让士兵先后以三人一排.五人一排.七人一排地变换队 形,而他每次只掠一眼队伍的排尾就知道总人数了.输入多组数据,每组数据包含3个非负整数 ...
- 几个js框架
easyui适合做后端 bootstrap适合前端 layui 其实更偏向与后端开发人员使用,在服务端页面上有非常好的效果.
- Java基础_0304:构造方法
构造方法 如果要实例化新的对象,那么肯定需要使用关键字new来完成,但是除了new这个关键字之外,还有可能在对象实例化时为其进行一些初始化的准备操作,这个时候就需要构造方法的支持了 构造方法本身是一种 ...
- android Notification总结
在发送一个Notification前,我们需要准备好一个NotificationManager NotificationManager manager = (NotificationManager) ...
- 嵌入式开发平台迅为iTOP-4412开发板-ssh常见问题以及解决方法
一.基本网络,软件安装以及配置 ssh 软件无法登陆 Ubuntu,有可能是网络不通.SSH 软件未安装.环境变量没配置.防 火墙未关闭等. 1. 网络连接 使用 ssh 传输文件的前提是网络顺畅,即 ...
- 基于html2canvas实现网页保存为图片及图片清晰度优化
一.实现HTML页面保存为图片 1.1 已知可行方案 现有已知能够实现网页保存为图片的方案包括: 方案1:将DOM改写为canvas,然后利用canvas的toDataURL方法实现将DOM输出为包含 ...
- 刷题之路第三题--Longest Substring Without Repeating Characters
问题简介:求给定字符串中最长的字符不重复的字符串的长度 问题详解: 给定一个字符串,寻找给定字符串中包含的最长的字符不重复的字符串的长度 注:答案必须是子字符串,不是子序列 是连续的字符不重复的字符串 ...
- Zookeeper学习笔记4
开源客户端 ZkClient <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId ...
- STL 智能指针
转自: https://blog.csdn.net/k346k346/article/details/81478223 STL一共给我们提供了四种智能指针:auto_ptr.unique_ptr.sh ...
- Maya API Test
import maya.OpenMaya as OpenMaya import maya.OpenMayaMPx as OpenMayaMPx sl = OpenMaya.MSelectionList ...