CentOS7.3中的Nginx部署Angular项目

  • 我的 Angular 项目编译的命令是:ng build --prod --aot --base-href ./
  • 我的 CentOS7.3 中安装的 nginx 版本号是:1.16.1
  • 安装路径是 /etc/nginx,配置文件 angular.conf 在目录/etc/nginx/conf.d中的内容是:

(把该目录下的其他后缀是conf的文件都修改为:*.conf1了)

server {
  listen 80;
  server_name 192.168.190.131; # 我的 CentOS的IP地址
  root /chanchaw/app/angular; # 我的Angular编译后的文件放在这里

  location / {
      try_files $uri $uri/ /index.html;
  }
}
  • 浏览器中访问:http://192.168.190.131/index....
  • 页面显示一片空白,F12后看到错误提示
  • GET https://192.168.190.131/styles.d7daca3ef5ef8cb021d3.css net::ERR_CONNECTION_RESET
  • GET https://192.168.190.131/runtime-es2015.970e4ee50a9015fe307c.js net::ERR_CONNECTION_RESET
  • GET https://192.168.190.131/favicon.ico net::ERR_CONNECTION_RESET
  • CentOS 中查看 nginx服务:netstat -anput|grep nginx

结果显示:tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7453/nginx: master

  • 要如何解决?QQ = 409223171
阅读 3.4k
3 个回答

nginx config

server {
    listen       84;
    server_name  localhost;
    location / {
         root   /data/wwwroot/scada;
         index  index.html index.htm;
         try_files $uri $uri/ /index.html;
    }
    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

index.html

<base href="/">

问题解决了,要知道结果的,在下面回复我吧

放到阿里云OSS下面就行了,然后配置一下自己的域名,没必要自己再搭服务器

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题