首页 > 系统相关 >nginx 部署 前端 项目 Windows

nginx 部署 前端 项目 Windows

时间:2022-11-11 10:00:17浏览次数:38  
标签:index log Windows 前端 server nginx html error

1、下载nginx

https://nginx.org/en/download.html

2、解压

 

 

 

3、启动nginx,并访问http://localhost:80/

nginx 默认80端口

 

查看nginx是否启动

tasklist | find /i "nginx.exe"

查看nginx占用的端口

# 查询某个程序的PID

>tasklist | findstr "nginx.exe"

# 根据PID查看进程所占端口

>netstat -ano | findstr 20064

 

4、将前端包放到nginx根目录,并修改文件夹名称(修改为英文名)

 

 

 4、修改nginx.conf文件

 

 

 nginx.conf

#user  nobody;
worker_processes  1;

#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       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /api/ {
            proxy_pass http://10.1.13.86:8080;
        }
        
        location /{
            root    dist;
            index   index.html;
            add_header Cache-Control 'no-cache,no-store';
        }
        #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;
    #    }
    #}

}
View Code

5、重新启动nginx

# 进入nginx.exe所在目录,输入充cmd

nginx -s reload

或者先杀掉之前nginx,再启动

# 杀掉nginx

taskkill /f /t /im nginx.exe

注意:

后端的ip :  proxy_pass http://10.1.13.86:8080;       千万别写成http://10.1.13.86:8080/ ,多加一个/ ,会造成302

 

 参考:https://blog.csdn.net/m0_49099550/article/details/113493189

https://blog.csdn.net/weixin_43066287/article/details/121104183

标签:index,log,Windows,前端,server,nginx,html,error
From: https://www.cnblogs.com/ychun/p/16879644.html

相关文章

  • 给windows服务加描述 sc description xxxxxxxxxx "需要修改成的描述"
    给windows服务加描述scdescriptionxxxxxxxxxx"需要修改成的描述"给windows服务加描述修改windows服务的描述scdescription xxxxxxxxxx "需......
  • 前端打包bulid后代码 放在 后端项目什么位置
    前端打包后的样子:  2放在项目的那个位置2.1对于index.html寻找项目根url,找见首页url,就找见了index.html的存放位置了2.2对于static文件夹找跟......
  • 前端项目开发流程
    项目完整流程需求分析1、了解背景为什么做这个事情2、质疑需求是否合理这个需求为什么要做,是否符合我们的产品,开发也是用户3、需求是否闭环需求是否考虑全面,分析功......
  • Nginx构建高可用集群概念介绍
    相关概念单独故障:指某个节点故障,整个系统将变得不可用。高可用:指系统无中断地执行其功能的能力,代表系统的可用性程度。集群:一组具有相同属性或功能的主机的集合,用于承担......
  • kkfileview在windows服务器部署指南
    本人负责维护一个文档管理系统,BS化后需要一个开源的、免费的(甲方不愿意掏钱,哈哈)在线预览软件,市面上在线预览软件比较众多,选择了两款比较优秀的来配合使用:(1)onlyoffice,介......
  • 小公司自建前端监控埋点体系,证明可行
    正文如下在去年,有过一次文字版的分享,当时系统还没有完全建设成型,大家可以结合这两篇一起看:技术探索:60天急速自研-前端埋点监控跟踪系统大浪子。本文为第五届-前端......
  • windows取消警报声
    目录Windows取消警报声前言步骤Windows取消警报声前言最近在使用Xshell时,当光标已经到行首再按退格键时就会发出警报声,虽然没有什么很大的影响,但是当我们要整行删除时多......
  • linux nginx上传文件配置
    1、参考nginx中上传文件大小报错500怎么办2、nignx配置server{listen8088;#listen443ssl;#ssl_certificate7249692_tlh.kikyo.co......
  • 前端页面之间传值的两种方式
    情景:前后端分离项目,如果一个页面在跳转另一个页面的同时,想传递数据给另一个页面使用,就涉及到前端页面之间传值的问题。主要有两个解决方案:cookie或localStorage(推荐)coo......
  • RabbitMQ windows下的安装与配置
    1、相关日志包含rabbitmq以及.net客户端的变更以及升级详情 2、rabbitmq安装方式介绍windows下的安装方式主要有以下两种:(1)、Usingchocolatey(2)、UsingtheInst......