美文网首页
Nginx系列2:nginx各配置段

Nginx系列2:nginx各配置段

作者: joyitsai | 来源:发表于2019-04-01 11:20 被阅读0次
nginx.conf配置文件:
// 全局区
worker_processes 1; 
// 有1个工作的子进程,可以自行修改,但太大无益,因为要争夺CPU,一般设置为 CPU数*核数

Event {
// 一般是配置nginx连接的特性
// 如1个worker能同时允许多少连接
 worker_connections  1024; // 这是指 一个子进程最大允许连1024个连接
}

http {  //这是配置http服务器的主要段
     Server1 { // 这是虚拟主机段
       
            Location {  //定位,把特殊的路径或文件再次定位 ,如image目录单独处理
            }             

     }

     Server2 {
     }
}


// 例子1: 基于域名的虚拟主机
    server {
        listen 80;  #监听端口
        server_name a.com; #监听域名

        location / {
                root /var/www/a.com;   #根目录定位
                index index.html;
        }
    }

// 例子2: 基于端口的虚拟主机配置

    server {
        listen 8080;
        server_name 192.168.1.204;

        location / {
                root /var/www/html8080;
                index index.html;
        }
    }

相关文章

  • Nginx系列2:nginx各配置段

    nginx.conf配置文件:

  • nginx采坑记

    采坑系列2-nginx 最近因为工作,需要配置nginx,初期nginx都运行的非常的顺利,在终端输入命令 ngi...

  • nginx(五)nginx cmd

    nginx cmd 1、启动nginx start nginx 2、修改配置文件并生效 测试nginx配置文件是否...

  • nginx https

    nginx -v nginx -V nginx -t 2.nginx.conf https配置 注意事...

  • nginx

    nginx 1.nginx安装 2.nginx 配置 3.nginx内置变量 4.nginx 配置文件介绍 5.n...

  • Nginx启用状态监控

    标签(空格分隔): nginx 1 在 server 段加上一个location 2 重载 Nginx 配置 3 ...

  • centos7系统下使用Nginx 配置搭建thinkphp5项

    1、进入nginx 配置文件目录 cd /usr/local/nginx/conf 2、编辑修改nginx配置...

  • Mac Nginx 配置

    1.安装 Nginx brew install nginx 2.启动nginx brew nginx 3.站点配置...

  • 4,nginx基础

    ubuntu+nginx+php 1,安装nginx 2,配置php-fpm 3,nginx配置 4,重启服务 参...

  • mac布置lnmp环境

    1.homebrew 安装nginx;版本:1.15.8;使用nginx -V 命令可以查看 各安装路径 配置...

网友评论

      本文标题:Nginx系列2:nginx各配置段

      本文链接:https://www.haomeiwen.com/subject/edwmbqtx.html