1.nginx的配置文件nginx.conf

cd /etc/nginx/

vim nginx.conf

打开后的文件为:

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;//所有nginx 的content-type的配置
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;//子配置文件
}

2.nginx.conf的子配置文件(/etc/nginx/conf.d/*.conf)

cd /etc/nginx/conf.d/

ls

vim default.conf

打开的文件为

server {
listen 80;//server所监听的端口
server_name localhost;//server的服务名,服务用域名方式访问的域名的地址

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {//一个server可以有多个location,location /代表一个server当没有其他的路径的时候默认采用/,访问所有的首页路径或自路径都进入到这个location中进行访问
root /usr/share/nginx/html;//location里面所返回的页面的路径
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 404 /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;
"default.conf" 45L, 1096C

nginx默认配置和默认站点启动的更多相关文章

  1. 在Nginx上配置多个站点

    有时候你想在一台服务器上为不同的域名运行不同的站点.比如www.siteA.com作为博客,www.siteB.com作为论坛.你可以把两个域名的IP都解析到你的服务器上,但是没法在Nginx的根目录 ...

  2. omcat配置多域名站点启动时项目重复加载多次

    在tomcat中配置多个Host的时候, 出现项目重复启动多次的情况. 刚开始以为是spring boot发布项目的时候自带了一个tomcat引起的, 后来发现不是 参考了这两篇文章, 解决问题 ht ...

  3. 使用Typescript重构axios(十五)——默认配置

    0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...

  4. webpack 4:默认配置

    webpack 4:默认配置 entry 默认: ./src/index.js(注意: 路径必须带上./): entry: './src/index.js', output 默认最后路径: ./dis ...

  5. (三)Spring Boot 官网文档学习之默认配置

    文章目录 继承 `spring-boot-starter-parent` 覆盖默认配置 启动器 原文地址:https://docs.spring.io/spring-boot/docs/2.1.3.R ...

  6. CentOS7安装Nginx及配置

    Nginx是一款轻量级的网页服务器.反向代理服务器.相较于Apache.lighttpd具有占有内存少,稳定性高等优势.**它最常的用途是提供反向代理服务.** 安装   在Centos下,yum源不 ...

  7. 【Nginx安装】CentOS7安装Nginx及配置

    [Nginx安装]CentOS7安装Nginx及配置 2018年03月05日 11:07:21 阅读数:7073 Nginx是一款轻量级的网页服务器.反向代理服务器.相较于Apache.lighttp ...

  8. nginx 默认配置语法和日志的format

    nginx 默认配置 查看有nginx哪些默认配置文件,打开/etc/nginx/nginx.conf文件,查看尾行部分 会默认将/etc/nginx/conf.d/文件下其他以.conf结尾的配置文 ...

  9. Nginx.conf配置文件默认配置块略解

    #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...

随机推荐

  1. C# 图像处理:获取鼠标位置信息(全局)

    Point ms = Control.MousePosition; //获取鼠标位置 this.label2.Text = string.Format("{0}:{1}", ms. ...

  2. tensorflow serving 之minist_saved_model.py解读

    最近在学习tensorflow serving,但是就这样平淡看代码可能觉得不能真正思考,就想着写个文章看看,自己写给自己的,就像自己对着镜子演讲一样,写个文章也像自己给自己讲课,这样思考的比较深,学 ...

  3. unity中Android环境变量配置

    http://www.cnblogs.com/windytrees/p/7533477.html

  4. python进程之守护进程

    标签(空格分隔): 守护进程 主进程创建子进程,然后将该进程设置成守护自己的进程,守护进程就好比崇祯皇帝身边的老太监,崇祯皇帝已死老太监就跟着殉葬了: 关于守护进程需要强调两点: 其一:守护进程会在主 ...

  5. 破解webstorm

    补丁下载链接:http://idea.lanyus.com/ 第一步:将补丁复制到安装目录的bin目录下 第二步:修改同目录下的 WebStorm.exe.vmoptions 和WebStorm64. ...

  6. vue 学习1

    .static{ border-radius:4px; } .active { width: 100px; height: 100px; background: green; } .text-dang ...

  7. web漏洞详解及修复建议

    1.漏洞描述 跨站脚本攻击(Cross-site scripting,通常简称为XSS)发生在客户端,可被用于进行窃取隐私.钓鱼欺骗.偷取密码.传播恶意代码等攻击行为. 恶意的攻击者将对客户端有危害的 ...

  8. day17 正则表达式 re模块和hashlib模块

    今日内容 1. re&正则表达式(*****) 注:不要将自定义文件命名为re import re re.findall(正则表达式,被匹配的字符串) 拿着正则表达式去字符串中找,返回一个列表 ...

  9. Appium1.6启动ios9.3报错Original error: Sdk '9.3.5' was not in list of simctl sdks

    问题: 使用Apppium1.6启动ios9.3报错Original error: Sdk '9.3.5' was not in list of simctl sdks   我的启动配置如下 {   ...

  10. js setInterval参数设置

    语法  setInterval(code,interval) ①可以有第三个参数,第三个参数作为第一个参数(函数)的参数 ②第一个参数是函数,有三种形式: 1.传函数名,不用加引号,也不加括号,如 s ...