Extract the downloaded file to a folder, for example, C:\nginx.
Build your app
Build your Angular app using the following command: This will generate the dist folder under your project root. for example, D:\codes\angular\angular-router.
1
ng build --prod
Setup Nginx
Open a command prompt as an administrator.
Navigate to the Nginx directory.
Open the conf/nginx.conf file in a text editor.
Find the http | server block and add the following line:
1 2 3 4 5 6 7 8
server { listen80; server_name localhost; location / { root D:/codes/angular/angular-router/dist; index index.html index.htm; } }
Start Nginx
Open a command prompt as an administrator.
Navigate to the Nginx directory.
Start Nginx using the following command:
1
start nginx
Restart Nginx
1
nginx -s reload
Stop Nginx
1
nginx -s stop
Check Nginx configuration
1
nginx -t
If the configuration is valid, you will see a message like this:
1 2
nginx: the configuration file C:/nginx/conf/nginx.conf syntax is ok nginx: configuration file C:/nginx/conf/nginx.conf test is successful