欢迎来到梦飞科技

服务器租用

当前优惠活动:

Nginx主配置文件参数详细解释说明

  a.上面博客说了在Linux中安装nginx。

  b.当Nginx安装完毕后,会有相应的安装目次,安装目次里的nginx.confg为nginx的主设置文件,nginx主设置文件分为4部门,main(全局设置)、server(主机设置)、upstream(负载平衡处事器配置)以及location(URL匹配特定位置的配置),这四者的干系是:server担任main,location担任server,upstream既不会担任其它配置也不会被担任。

  c.Nginx是一个署理处事器,一般环境下,网站是不能陈设在Nginx下的,好比用Java开拓的JavaWeb措施,我们陈设在tomcat下,德国机房主机 波兰服务器,然后利用Nginx署理将网址指向tomcat即可。

 #  kencery 注释说明Nginx文件
 #  时间:2016-1-19
 #  进修内容,只是来自互联网,有版权问题请接洽我删除。
 ########   Nginx的main(全局设置)文件
 #指定nginx运行的用户及用户组,默认为nobody
 #user  nobody;   
 #开启的线程数,一般跟逻辑CPU核数一致
 worker_processes  1;
 #定位全局错误日志文件,级别以notice显示,尚有debug,info,warn,error,crit模式,debug输出最多,crir输出最少,按照实际情况而定
 #error_log  logs/error.log;
 #error_log  logs/error.log  notice;
 #error_log  logs/error.log  info;
 #指定历程id的存储文件位置
 #pid        logs/nginx.pid;
 #指定一个nginx历程打开的最多文件描写符数目,受系统历程的最大打开文件数量限制
 #worker_rlimit_nofile 65535
 events {
     #配置事情模式为epoll,除此之外尚有select,poll,kqueue,rtsig和/dev/poll模式
     #use epoll;
     #界说每个历程的最大毗连数,受系统历程的最大打开文件数量限制。
     worker_connections  1024;
 }
 #######Nginx的Http处事器设置,Gzip设置
 http {
     #主模块指令,实现对设置文件所包括的文件的设定,可以淘汰主设置文件的巨大度,DNS主设置文件中的zonerfc1912,acl根基上都是用include语句。
     include       mime.types;
     #焦点模块指令,智力默认配置为二进制流,也就是当文件范例未界说时利用这种方法
     default_type  application/octet-stream;
     #下面代码为日志名目标设定,main为日志名目标名称,可自行配置,后头引用
     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
     #                  '$status $body_bytes_sent "$http_referer" '
     #                  '"$http_user_agent" "$http_x_forwarded_for"';
     #引用日志main
     #access_log  logs/access.log  main;
     #配置答允客户端请求的最大的单个文件字节数
     #client_max_body_size 20M;
     #指定来自客户端请求头的headebuffer巨细
     #client_header_buffer_size  32k;
     #指定毗连请求试图写入缓存文件的目次路径
     #client_body_temp_path /dev/shm/client_body_temp;
     #指定客户端请求中较大的动静头的缓存最大数量和巨细,今朝配置为4个32KB
     #large client_header_buffers 4 32k;
     #开启高效文件传输模式
     sendfile        on;
     #开启防备网络阻塞
     #tcp_nopush     on;
     #开启防备网络阻塞
     #tcp_nodelay    on;
     #配置客户端毗连生存勾当的超时时间
     #keepalive_timeout  0;
     keepalive_timeout  65;
     #配置客户端请求读取超时时间
     #client_header_timeout 10;
     #配置客户端请求主体读取超时时间
     #client_body_timeout 10;
     #用于配置相应客户端的超时时间
     #send_timeout 
     ####HttpGZip模块设置
     #httpGzip modules
     #开启gzip压缩
     #gzip  on;
     #配置答允压缩的页面最小字节数
     #gzip_min_length 1k;
     #申请4个单元为16K的内存作为压缩功效流缓存
     #gzip_buffers 4 16k;
     #配置识别http协议的版本,默认为1.1
     #gzip_http_version 1.1;
     #指定gzip压缩比,1-9数字越小,压缩比越小,速度越快
     #gzip_comp_level 2;
     #指定压缩的范例
     #gzip_types text/plain application/x-javascript text/css application/xml;
     #让前端的缓存处事器进过gzip压缩的页面
     #gzip_vary on;  
     #########Nginx的server虚拟主机设置
     server {
         #监听端口为 80
         listen       80;
         #配置主机域名
         server_name  localhost;
         #配置会见的语言编码
         #charset koi8-r;
         #配置虚拟主时机见日志的存放路径及日志的名目为main
         #access_log  logs/host.access.log  main;
         #配置虚拟主机的根基信息
         location / {
             #配置虚拟主机的网站根目次
             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;
         #}
     }
     # another virtual host using mix of IP-, name-, and port-based configuration
     #
     #server {
     #    listen       8000;
     #    listen       somename:8080;
     #    server_name  somename  alias  another.alias;
     #    location / {
     #        root   html;
     #        index  index.html index.htm;
     #    }
     #}
     # HTTPS server
     #
     #server {
     #    listen       443 ssl;
     #    server_name  localhost;
     #    ssl_certificate      cert.pem;
     #    ssl_certificate_key  cert.key;
     #    ssl_session_cache    shared:SSL:1m;
     #    ssl_session_timeout  5m;
     #    ssl_ciphers  HIGH:!aNULL:!MD5;
     #    ssl_prefer_server_ciphers  on;
     #    location / {
     #        root   html;
     #        index  index.html index.htm;
     #    }
     #}
 }

  a.我在tomcat下陈设了一个javaweb项目,tomcat安装的处事器IP为:192.168.37.136,陈设的项目在tomcat下的会见解点为:http://192.168.37.136:8080/lywh/

  b.我在IP为192.168.37.133的处事器下面安装乐成了Nginx。

  c.那怎么样将tomcat下陈设的网站利用Nginx署理呢?,修改Nginx的设置文件,修改呼吁:vim /usr/local/nginx/conf/nginx.conf

梦飞科技 - 全球数据中心基础服务领先供应商

Copyright © 2003-2019 MFISP.COM. 国外服务器租用 IDC公司 版权所有 粤ICP备11019662号