Deploy Angular app on Apache server
I have described the deployment in steps for a new server which does not have any software installed, but if you have those software installed, just skip those steps and move on to next.I am using aws Amazon Linux 2023 for demo, but the deployment will work for any linux server.Installations
1. download nvm. NVM is a node version manager and in order to install Node and npm, first nvm is to be installed using following commands
2. next install node and npm, the version should be the version as your application, if version is not given, the latest version will get installed
3. install angular using npm, here again if the version is not given while executing command the latest version of angular will be installed
4. for getting the code from any of your git repositories, install git package, skip this step if the code can be copied using any other way like ftp, winscp etc.
5. install apache server
Deployment
6. copy the code to server directory wherever you want
7. build the angular app to a dist folder
8. copy the files from dist folder to /var/www/html, you must have access and permission to copy the files using sudo
9. start the apache server
you must get your application running, if you give the ip address of the server or the website name if any dns is attached to the ip.
1. download nvm. NVM is a node version manager and in order to install Node and npm, first nvm is to be installed using following commands
/curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
. ~/.nvm/nvm.sh
. ~/.nvm/nvm.sh
2. next install node and npm, the version should be the version as your application, if version is not given, the latest version will get installed
nvm install <<version>>
3. install angular using npm, here again if the version is not given while executing command the latest version of angular will be installed
npm install -g @angular/cli@<<version>>
4. for getting the code from any of your git repositories, install git package, skip this step if the code can be copied using any other way like ftp, winscp etc.
sudo dnf install git
5. install apache server
sudo dnf install httpd
Deployment
6. copy the code to server directory wherever you want
git clone <<github or any other git repo url>>
7. build the angular app to a dist folder
cd /path/where/angular/code/is/copied
ng build
ng build
8. copy the files from dist folder to /var/www/html, you must have access and permission to copy the files using sudo
sudo cp -r ./dist/<<webapp>>/* /var/www/html/
9. start the apache server
sudo systemctl start httpd
you must get your application running, if you give the ip address of the server or the website name if any dns is attached to the ip.