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

时间:2018-05-10 14:06:14

标签: linux angular deployment

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

  
      
  1. 运行构建--prod
  2.   
  3. 通过pscp
  4. 复制linux服务器上某个文件夹的dist文件夹中的文件   

现在,当我尝试访问http://hostname/folderPath/index.html这样的文件夹时,没有任何内容出现。我知道我错过了一些步骤,任何人都可以帮我部署应用程序。

2 个答案:

答案 0 :(得分:1)

根据我们的讨论,您说您尚未设置网址重写规则。

根据您用于托管应用程序的内容,您需要设置URL重写规则。

请参阅official docs

对于linux服务器

Apache:

RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

NGINX:

try_files $uri $uri/ /index.html;

答案 1 :(得分:0)

请勿删除“基本href”,它将无法正常工作 这样做对我有用吗?

<base href="" />