Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy Angular webApp on cPanel

Tags:

angular

cpanel

I need to deploy my angular 6 app on cPanel. Can someone guide me the steps?

I cant't find configuration folder in cPanel.

like image 458
Coder Avatar asked Sep 01 '18 13:09

Coder


People also ask

What is the best server to deploy Angular app?

Firebase hosting is the best hosting to use to deploy your angular app or react app.


2 Answers

STEPS

Create a production build by using following command.

ng build --prod

You will get few production errors, unless you don't fix them you won't be able to create production build.

You will find new folder dist in project folder at root. Open that folder, there is index.html file containing base href (href="/"). Replace "/" with the suitable path where you want to upload dist.

Open FileZilla, connect with server by using proper credentials. Open folder where you want to upload the dist on remote server. Upload the contents in dist folder on remote server location. Please don't forget to change the base href, otherwise it will take the path from root by default.

Important part is to add the ".htaccess" file, unless you don't add it, you won't be able to route from home page to somewhere else. File not found error will be displayed.

How to create a .htaccess file ??

.htaccess file is totally depends on which server you are going to use... There is different server configuration for each one like Apache, NGinx, IIS, etc

For more details please refer following documentation of Angular app deployment.

Angular app deployment documentation

like image 57
Raj Avatar answered Oct 16 '22 15:10

Raj


Step 1: Run "ng build --watch"

Step 2: Upload the files in a "dist" folder to your hosting environment.

Step 3: Update the index.html to,

    <base href="/"> **to** <base href="/projectDeployPath/">
like image 24
Muthulakshmi M Avatar answered Oct 16 '22 16:10

Muthulakshmi M