Created
December 30, 2019 11:48
-
-
Save gokman/fa1b1ab0b14afd68b9a9142f39091db3 to your computer and use it in GitHub Desktop.
multiple angular app configuration for nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. build app1 project with prod flag | |
ng build --prod | |
2. copy files under dist folder to the server | |
scp -r dist/app1/* {username}@{ip address of server}:/var/www/app1/ | |
3. set base href of application (app1 works on /) | |
<base href="/"> | |
4. build app2 project with prod flag | |
ng build --prod | |
5. copy files under dist folder to the server | |
scp -r dist/app2/* {username}@{ip address of server}:/var/www/app2/ | |
6. set base href of application (app2 works on /app2/) | |
<base href="/app2/"> | |
7. make nginx configuration in sites-available/my_app file | |
server { | |
listen 8080; | |
server_name {ip address of server}; | |
location / { | |
alias /var/www/app1/; | |
try_files $uri /index.html; | |
} | |
location /app2/ { | |
alias /var/www/app2/; | |
try_files $uri /app2/index.html; | |
} | |
} | |
8. create symbolic link of above configuration | |
ln -s sites-available/my_app sites-enabled/ | |
9. restart nginx | |
systemctl restart nginx | |
10. go app1 | |
http://{server address}/ | |
11. go app2 | |
http://{server address}/app2/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
same it didn't work for me with apache2