【发布时间】:2020-08-29 17:44:54
【问题描述】:
在本地构建和运行 Angular Universal 之后,我正在尝试部署到 apache 服务器。我正在将 dist 文件夹移动到公共 html。
我运行node dist/server/main.js,它从端口 localhost:4000 开始,当我 curl localhost:4000 时,我得到了内容。
附言我也安装了 pm2,当我尝试
pm2 start dist/server/main.js启动服务器但当我尝试 curl 它显示 Internal server error
我还编辑了 .conf 文件以代理到 localhost:4000:
ProxyPreserveHost On
ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/
当我尝试访问它时显示
虚拟主机文件
DocumentRoot /var/www/domain/public/dist/browser
<Directory /var/www/domain>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain [OR]
RewriteCond %{SERVER_NAME} =domain
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ProxyPreserveHost On
ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/
【问题讨论】:
-
显示您的完整虚拟主机。 Root 设置不正确,应该设置为
dist/browser。此外,Internal server error是默认的 apache 错误页面。如果您需要帮助,您需要查看日志并指出真正的错误... -
@David - 感谢您的参与。我用虚拟主机文件编辑了帖子
标签: angular apache ubuntu angular-universal