Nginx核心配置文件介绍,kafka入门与实践百度云

events段


events {

使用的网络I/O模型,Linux推荐使用epoll模式 FreeBSD推荐使用kqueue模型

use epoll;

单个woker进程支持的最大连接数

worker_connections 1024;

}

http段


【一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义】

开源分享完整内容戳这里

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 " bodybytessent"http_referer" ’

‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""http_x_forwarded_for”’;

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

定义作为web服务器的相关属性 可以有多个

server {

监听的端口

listen 80;

服务名称

server_name localhost;

字符集

#charset koi8-r;

#access_log logs/host.access.log main;

定义一个虚拟主机的属性,所有的web服务必须定义成一个虚拟主机

location / {

资源存放的根目录在 html文件夹下

root 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 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;

#}

}

Nginx的虚拟主机配置

===========================================================================

了解了nginx.conf核心配置文件中基础的内容后,我们来看看这样一个需求,比如说我们现在要搭建三个服务,分别是bbs服务,门户系统和公司内部系统,这时我们可以通过三个web服务来搭建,但为了方便我们可以利用nginx的虚拟主机来实现这三个服务,具体怎么做呢?如下:

在这里插入图片描述

1.首先在nginx的根目录下创建三个文件夹:bbs,edu,www

在这里插入图片描述

2.分别在这三个文件夹中放入对应的资源文件,我们随便放入一个html页面即可(能区别即可)

在这里插入图片描述

3.修改nginx.conf配置文件,添加三个server配置

server {

listen 80;

虚拟主机配置

server_name bbs.gupao.com;

#charset koi8-r;

#access_log logs/host.access.log main;

虚拟主机对应的服务的资源地址

root /usr/local/nginx/bbs;

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 /50x.html;

location = /50x.html {

root html;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值