美文网首页
Centos7 下安装nginx

Centos7 下安装nginx

作者: 林亚希 | 来源:发表于2019-04-30 14:29 被阅读0次

    安装命令

    yum install -y nginx
    

    简单配置

    配置文件
    /etc/nginx/nginx.conf
    通常情况下。我们会把每个配置分开放置在
    /etc/nginx/conf.d这个目录下

    cd /etc/nginx/conf.d
    vi ceping.conf
    
     server {
            listen       80;#这里写你的端口。一般是80
            server_name  这里写你的域名;
            charset utf-8;
            client_max_body_size 20m;
    
            location / {
                    proxy_pass http://localhost:8080/;#这里写映射端口,入tomcat一把是8080
                    proxy_set_header   Host    $host:80;
                    proxy_set_header   X-Real-IP   $remote_addr;
                    proxy_set_header   X-Forwarded-For     
                   $proxy_add_x_forwarded_for;
            }
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
        }
    
    

    启动

    systemctl start nginx
    

    测试nginx配置文件

    nginx -t
    

    修改完成后重新加载配置文件

    nginx -s reload
    

    相关文章

      网友评论

          本文标题:Centos7 下安装nginx

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