将 angular-universal 部署到 apache 服务器 (Angular 9)
Deploy angular-universal to apache server (Angular 9)
构建和 运行 angular 本地通用后,我正在尝试部署到 apache 服务器。我正在将 dist 文件夹移动到 public html.
我 运行 node dist/server/main.js
它在端口 localhost:4000 上启动,当我卷曲时 localhost:4000 我正在获取内容。
p.s. I have also install pm2, and when I try pm2 start dist/server/main.js
starts the server but when I try to curl it shows 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/
由于我使用的是 Let's Encrypt CA,它会在 /etc/apache2/sites-available
中创建其 .conf 文件
yourdomain-le-ssl.conf
所以从 yourdomain.conf
文件代理到 localhost:4000 的配置不正确,从 yourdomain-le-ssl.conf
代理是正确的
构建和 运行 angular 本地通用后,我正在尝试部署到 apache 服务器。我正在将 dist 文件夹移动到 public html.
我 运行 node dist/server/main.js
它在端口 localhost:4000 上启动,当我卷曲时 localhost:4000 我正在获取内容。
p.s. I have also install pm2, and when I try
pm2 start dist/server/main.js
starts the server but when I try to curl it shows 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/
由于我使用的是 Let's Encrypt CA,它会在 /etc/apache2/sites-available
yourdomain-le-ssl.conf
所以从 yourdomain.conf
文件代理到 localhost:4000 的配置不正确,从 yourdomain-le-ssl.conf
代理是正确的