0

我安装了 Angular 6,它在我的本地机器上运行。但不要运行另一台连接本地网络的机器。我已经尝试了这些步骤,但没有使用。

ng serve --host 10.0.136.126 // http://10.0.136.126:4200
ng serve --host 0.0.0.0 // http://10.0.136.126:4200
ng serve --host=0.0.0.0 // http://10.0.136.126:4200
ng serve --host=0.0.0.0 --disable-host-check // http://10.0.136.126:4200
ng serve --host 10.0.136.126 --disable-host-check // http://10.0.136.126:4200

上面的命令在我的机器上运行良好,但在连接本地网络的同事机器上却不行。我正在使用ubuntu 16.04,并在 ubuntu 和 windows 机器上进行了测试。版本:

Angular CLI: 6.0.8
Node: 8.11.3
OS: linux x64
Angular: 6.0.4

node --version => 6.1.0
npm --version => 8.11.3

但我可以在其他机器上使用http://10.0.136.126/phpmyadmin访问我的 phpmyadmin 或任何 php 项目。

4

2 回答 2

2

是的,罪魁祸首是 ubuntu 16.04 机器中带有端口号的防火墙。必须检查防火墙。并添加端口号

sudo ufw allow 4200/tcp
于 2018-06-18T11:25:02.813 回答
0

If your are accessing your php-projects and phpMyAdmin this means there is already a server running.

So in order to use your angular project you can easily deploy on the server.

  1. run ng build --base-herf . // dont forget the dot
  2. copy the dist folder to the server's www folder.

    • if you are using apache copy the dist folder and past it in the /var/www/html

Then you can access your angular project http://10.0.136.126/dist

Let me know if this helps or not.

于 2018-06-18T11:17:03.747 回答