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. 通用坐标投影转换器Uneversal Coord Transformer

    关键词:投影,重投影,坐标转换,坐标系,空间参考,北京54,西安80,中国2000,WGS84,UTM,墨卡托,网络墨卡托 软件名称:通用坐标投影转换器Uneversal Coord Transfor ...

  2. Unity资源打包之Assetbundle

    转  Unity资源打包之Assetbundle 本文原创版权归 csdn janeky 所有,转载请详细注明原创作者及出处,以示尊重! 作者:janeky 原文:http://blog.csdn.n ...

  3. http://www.cnblogs.com/wuyunfei/p/4277226.html

    http://www.cnblogs.com/wuyunfei/p/4277226.html

  4. spring boot 访问jsp 弹出下载

    在pom.xml中加入以下jar 包 <!-- 引入Spring Boot 内嵌的Tomcat对jsp的解析包--><dependency> <groupId>or ...

  5. 吴裕雄 python深度学习与实践(3)

    import threading, time def doWaiting(): print('start waiting:', time.strftime('%S')) time.sleep(3) p ...

  6. php loop循环 拿到键名

    {loop $nianjian['dache'] $key  $v}        $key能拿到键名(微擎系统试过可以)

  7. Python 基础常用

    .连接符: + .基本类型: [] {} () list set :无序,不重复的集合 数据初始化: a = set('a','b'); 或者 {'1'} #只能初始化空的集合: 相关函数: 添加数据 ...

  8. java.lang.IllegalAccessError: tried to access method

    java.lang.IllegalAccessException: access to method denied 06-23 16:12:39.128 1253-1253/com.hbjyjt.oa ...

  9. linux centos 基本命令

    init 3 进入命令行界面. init 5 进入图形界面. ifconfig 查询IP地址. nmtui 设置网卡. su - root 是切换到root账号使用,使用的是root用户的环境变量:s ...

  10. 1.5、CDH 搭建Hadoop在安装之前(定制安装解决方案)

    Cloudera托管两种类型的软件存储库,您可以使用它们来安装诸如Cloudera Manager或CDH-parcel存储库和软件包存储库之类的产品. 在大多数情况下,这些存储库是有效的解决方案,但 ...