deploying angular app with nginx on rocky linux

step by step guide to deploy an angular application

· by Aron Kovacs

1. install nginx

Update your system and install Nginx on Rocky Linux:

sudo dnf update sudo dnf install nginx

Start and enable Nginx service:

sudo systemctl start nginx sudo systemctl enable nginx sudo systemctl status nginx

Configure firewall for HTTP traffic:

sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload
2. build angular app

On your local development machine, build your Angular app:

ng build --configuration production
3. transfer files

Navigate to your build directory and upload files to server:

cd /path/to/your/project/dist/project-name/browser scp -r * root@your-server-ip:/usr/share/nginx/html
4. configure nginx

Install text editor if needed:

sudo dnf install nano

Create and edit Nginx configuration:

sudo nano /etc/nginx/conf.d/your-site.conf

Add the following configuration:

server { listen 80; server_name your-domain.com www.your-domain.com; root /usr/share/nginx/html; location / { try_files $uri $uri/ /index.html; } }
5. set permissions

Configure proper permissions and SELinux:

sudo chown -R nginx:nginx /usr/share/nginx/html sudo chmod -R 755 /usr/share/nginx/html sudo setsebool -P httpd_can_network_connect 1
6. setup ssl (optional)

Install and configure Certbot for SSL:

sudo dnf install epel-release sudo dnf update sudo dnf install certbot python3-certbot-nginx sudo certbot --nginx -d your-domain.com
7. verify deployment

Test Nginx configuration and restart:

sudo nginx -t sudo systemctl restart nginx

Monitor Nginx logs if needed:

tail -f /var/log/nginx/error.log
Note: Replace placeholder values (your-domain.com, your-server-ip) with your actual values. Always ensure your server's security by properly configuring firewalls and keeping software updated.