nginx配置文件解析

#nginx 监听原理 先监听端口 --> 再配置域名 -->匹配到就访问local 否则 没有匹配到域名就默认访问第一个监听端口的local地址

vi nginx.conf

user nobody nobody; # 运 nginx的所属组和所有者
worker_processes 2; # 开启两个 nginx工作进程,一般几个 CPU核心就写几
error_log logs/error.log notice; # 错误日志路径
pid logs/nginx.pid; # pid 路径
events {
worker_connections 1024; # 一个进程能同时处理1024个请求
}
http {
  include mime.types;
  default_type application/octet-stream;

log_format main $remote_addr – r e m o t e u s e r [ remote_user [ remoteuser[time_local] “$request” $status b o d y b y t e s s e n t “ body_bytes_sent “ bodybytessenthttp_referer” h t t p u s e r a g e n t ” “ http_user_agent” “ httpuseragenthttp_x_forwarded_for” ;
  access_log logs/access.log main; # 默认访问日志路径
  sendfile on;
  keepalive_timeout 65; # keepalive超市时间
  # 开始配置一个域名,一个server配置段一般对应一个域名
  server {
    listen 80; # 监听端口()
    # 在本机所有ip上监听80,也可以写为192.168.1.202:80,这样的话,就只监听192.168.1.202 上的80口
    server_name www.heytool.com; # 域名
    root /www/html/www.heytool.com; # 站点根目录(程序目录)
    index index.html index.htm; # 索引文件
    # 可以有多个 location
    location / {
      #proxy_pass www.baidu.com # 跳到 百度页面 (网址)
      root /www/html/www.heytool.com; # 站点根目录(程序目录) (本地的路径)
    }

error_page 500 502 503 504 /50x.html;
    # 定义错误页面,如果是500错误,则把站点根目录下的50x.html返回给用户
    location = /50x.html {
    root /www/html/www.heytool.com;
  }
}

#nginx 监听原理 先监听端口 --> 再配置域名 -->匹配到就访问local 否则 没有匹配到域名就默认访问第一个监听端口的local地址

//看到ok和successful,说明配置文件没问题

/usr/local/nginx-1.0.6/sbin/nginx –t

nginx: the configuration file /usr/local/ nginx-1.0.6/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/ nginx-1.0.6/conf/nginx.conf test is successful

#启动 nginx

/usr/local/nginx-1.0.6/sbin/nginx

#重启 nginx

/usr/local/nginx-1.0.6/sbin/nginx -s reload

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值