为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕姐8265434 2021-04-10 08:59:30
我是在Linux上部署角度应用程序的新手,我曾经在IIS上做过,这很简单。我有一台可以通过Putty访问的Linux服务器。我想在此服务器上部署我的angular 5应用程序。到目前为止,我已经执行了以下步骤运行ng build --prod通过pscp将文件复制到linux服务器上一个文件夹的dist文件夹中现在,当我尝试访问http://hostname/folderPath/index.html之类的文件夹时,什么也没出现。我知道我缺少一些步骤,任何人都可以帮助我部署应用程序。
查看完整描述

3 回答

?
RISEBY

TA贡献1856条经验 获得超5个赞

只需卸下底座从标签的index.html就是这样


<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Angular App</title>

<base href="/">

Some more code

Don't do anything to this

删除后,您的代码将如下所示


    <!doctype html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>Angular App</title>

    Some more code

    Don't do anything to this


查看完整回答
反对 回复 2021-04-16
?
茅侃侃

TA贡献1842条经验 获得超21个赞

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


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


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;


查看完整回答
反对 回复 2021-04-16
?
蓝山帝景

TA贡献1843条经验 获得超7个赞

不要删除“ base href”,它将无法正常工作对我来说,这样做有效:

<base href="" />


查看完整回答
反对 回复 2021-04-16
  • 3 回答
  • 0 关注
  • 319 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信