Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Angular app on xampp server?

Tags:

php

angular

xampp

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.

like image 652
Ahmer Ali Ahsan Avatar asked Jun 19 '17 22:06

Ahmer Ali Ahsan


People also ask

How do I run an angular project in xampp?

Just run your angular 2 application using the CLI, and add the proxy to use the services that are in xampp.

Can we run angular in Apache server?

We need to achieve 2 tasks: =>Serve the angular application from the Apache Server. =>The Apache Server must compress the contents of the angular build before serving it in the browser. To achieve these tasks, we need to make a few changes to the Apache24/conf/httpd.


2 Answers

Here is my answer.

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

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="/">

into

<base href="./">

and build my app using:

ng build --prod

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

localhost:8080/dist/

output

App works

like image 195
Ahmer Ali Ahsan Avatar answered Sep 24 '22 05:09

Ahmer Ali Ahsan


You can host it on any server by first building the angular project using the command line:

ng build --base-href "/football/" --prod

This base href will mean that it expects the final server to be something like: localhost:8080/football/.

You want to get everything that is made in the dist folder and paste it into your server inside a folder called football.

like image 33
Josh Dando Avatar answered Sep 23 '22 05:09

Josh Dando