沃梦达 / 编程问答 / php问题 / 正文

如何在 xampp 服务器上运行 Angular 应用程序?

How to run Angular app on xampp server?(如何在 xampp 服务器上运行 Angular 应用程序?)

本文介绍了如何在 xampp 服务器上运行 Angular 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Angular 2 和 php.在我使用 Angular 2 开始 PHP 之前.我已经在服务器 localhost:3000 上使用 node.js 完成了 Angular 2.现在使用 PHP,我如何使用 xampp 服务器配置我的 Angular 2 应用程序,以便我的服务器代码在 localhost:8080 上运行.请帮助我.

I'm working with Angular 2 with php. Before I started PHP with Angular 2. I have done Angular 2 with node.js on server localhost:3000. Now with PHP, how I can configure my Angular 2 app with xampp server so my server code is running on localhost:8080. Please help me on this.

推荐答案

这是我的答案.

您可以仅使用 Angular2 包编写 Angular2 应用程序,而无需使用节点、mamp 或 xampp 并托管该应用程序.参考

You can write Angular2 app just using Angular2 packages without using node or mamp or xampp and host that app. Ref

根据上述参考,我使用 angular 2 - cli 创建了我的应用程序之后我在我的根目录 index.html 文件中做了一点改动:

According to the above reference I created my app using angular 2 - cli after that I made a little change in my root directory index.html file which is:

<base href="/">

进入

<base href="./">

并使用以下方法构建我的应用程序:

and build my app using:

ng build --prod

复制 dist 文件夹并将其粘贴到我的 xampp htdocs 文件夹中并使用以下命令访问该站点:

copy dist folder and paste it in my xampp htdocs folder and access the site using:

本地主机:8080/dist/

localhost:8080/dist/

输出

应用程序工作

这篇关于如何在 xampp 服务器上运行 Angular 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在 xampp 服务器上运行 Angular 应用程序?

基础教程推荐