Cpanel中的角度SSR部署

时间:2019-12-22 09:11:11

标签: node.js angular cpanel angular-universal

我正在尝试在Cpanel上部署一个角度通用项目,我上传了文件并安装了它

在子目录public_html / aqar_front中,我用以下代码在htaccess中添加了htaccess

<link rel="stylesheet" type="text/css" href="{% static 'css/custom.css' %}"/>

然后我运行此命令

DirectoryIndex disabled
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:4000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:4000/$1 [P,L]

在浏览器中工作正常

enter image description here

但是,正如您所知,当我关闭终端时,应用程序停止了,因此我使用pm2使其保持运行,但在浏览器中无法正常工作 enter image description here

我使用了此命令

npm run serve:ssr 

但是从浏览器中无法获得任何帮助,请 这是我的角度和节点js版本

  

Angular CLI:8.3.4   节点:12.13.1   操作系统:Linux x64   角度:8.2.6

1 个答案:

答案 0 :(得分:0)

好吧,任何遇到此问题的人,我运行local.js而不是server.js

 pm2 start local.js -- --port 4000 

现在工作正常