• Linux nginx安装步骤 centos7


    1.安装依赖:

    yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

    2.创建一个文件夹
    cd /usr/local
    mkdir nginx
    cd nginx

    3.下载解压tar包
    wget http://nginx.org/download/nginx-1.13.7.tar.gz
    tar -xvf nginx-1.13.7.tar.g

    4.编译
    cd /usr/local/nginx/nginx-1.13.7

    ./configure

    make

    make install

    5.配置nginx.conf(这里简单配置 修改了监听端口 跨域)

    #user  nobody;
    worker_processes  2;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        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  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
        server {
    	listen       3389 default_server;
            listen       [::]:3389 default_server;
            server_name  _;
            root         /usr/local/source;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
            }
    	location ^~ /res/ {
                    add_header Access-Control-Allow-Origin '*';
                    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
                    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
                root   /usr/local/source/;
            }
    
            #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;
            }
        }
    
    }
    

      6.启动(注意看清文件夹)

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

    ./nginx 启动

    ./nginx -s stop 关闭

    ./nginx -s reload 重启

    ./nginx -t 检查配置

  • 相关阅读:
    04-增删改查
    03-编写dao实现类方式
    02-基于注解的入门案例
    .net core api 图片上传与加载
    笔记一、数据库初始化 约定
    .net core MVC中级教程(四)
    .net core MVC中级教程(三)
    Windows 盘符映射
    c# 队列和堆栈
    isValidNode
  • 原文地址:https://www.cnblogs.com/AmbitiousMice/p/11419806.html
Copyright © 2020-2023  润新知