在Linux服务器上部署Angular 5应用程序

我是在Linux上部署角度应用程序的新手,我曾经在IIS上做过,这很简单。我有一台可以通过Putty访问的Linux服务器。我想在此服务器上部署我的angular 5应用程序。到目前为止,我已经执行了以下步骤

  1. 运行ng build --prod

  2. 通过pscp将文件复制到linux服务器上一个文件夹的dist文件夹中

现在,当我尝试访问http://hostname/folderPath/index.html之类的文件夹时,什么也没出现。我知道我缺少一些步骤,任何人都可以帮助我部署应用程序。


慕姐8265434
浏览 350回答 3
3回答

RISEBY

只需卸下底座从标签的index.html就是这样<!doctype html><html><head><meta charset="utf-8"><title>Angular App</title><base href="/">Some more codeDon't do anything to this删除后,您的代码将如下所示&nbsp; &nbsp; <!doctype html>&nbsp; &nbsp; <html>&nbsp; &nbsp; <head>&nbsp; &nbsp; <meta charset="utf-8">&nbsp; &nbsp; <title>Angular App</title>&nbsp; &nbsp; Some more code&nbsp; &nbsp; Don't do anything to this

茅侃侃

根据我们的讨论,您说您尚未设置URL重写规则。根据用于承载应用程序的内容,您需要设置URL重写规则。RewriteEngine On# If an existing asset or directory is requested go to it as it isRewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -dRewriteRule ^ - [L]# If the requested resource doesn't exist, use index.htmlRewriteRule ^ /index.htmlNGinx:try_files $uri $uri/ /index.html;

蓝山帝景

不要删除“ base href”,它将无法正常工作对我来说,这样做有效:<base&nbsp;href=""&nbsp;/>
打开App,查看更多内容
随时随地看视频慕课网APP