How to deploy angular 2/4/5/6 application from bitbucket to Nginx Server in AWS EC2:
Make sure you have installed following in your linux machines:
- Nginx server.
- Account in bitbucket (atleast in github to clone some angular app).
1. Create temp folder in root path and do git clone:
sudo git clone -b my-Branch https://YOURUSERNAME@bitbucket.org/YOURUSERNAME/YOURPROJECT
Here my-Branch is branch name, if you want the master to be cloned then your url will be like this,
sudo git clone https://YOURUSERNAME@bitbucket.org/YOURUSERNAME/YOURPROJECT
2. Now get into your project folder and run the below steps:
sudo sudo npm install
sudo sudo ng build --prod
sudo sudo given two times to solve the permission related issues, prefer to give two times only. (sudo sudo only).
Once the ng build –prod success, then you will be able to see the dist folder.
Make sure you copy only the content of the dist folder, instead of copying the dist folder itself.
This command can be used to copy your dist folder to html folder:
sudo cp -r /temp/YOURPROJECT/dist/* /usr/share/nginx/html/
Make sure you restarted nginx server after the new deployment,
sudo service nginx restart
390 total views, 2 views today