Web Front-end
JS Tutorial
How to launch an Angular project? Let's talk about the online process with nginx!How to launch an Angular project? Let's talk about the online process with nginx!
AngularHow to launch the project? The following article will talk about the launch process of Angular project in combination with nginx. I hope it will be helpful to everyone!

After we complete the angular project, how should you go online? [Related tutorial recommendations: "angular tutorial"]
Maybe you will answer:
It is not my bussiness. Right?
Indeed, as a pure front-end developer, after completing the development of the project, you do not need to touch the next online content.
However, as a developer, it is very important for us to understand the process of the project from development to launch.
Let’s explain it in combination with nginx.
Same for react and vue
Packaging project
What is used here is angular-cli generated project. After developing the project, you only need to run npm run build. builder will output according to the packaging content you preset in angular.json.

- outputPath: The packaged storage folder path
- index: Mount the template file
- main: The project's After the main entry file
- ...
is completed, you can view the packaged file through outputPath.

Install Nginx
We install it on the machine where we want to deploy the code, that is, the serverNginx. The operation is based on the yum source operation of centos.
# 安装nginx yum -y install nginx # 查看版本 nginx -v # 启动nginx systemctl start nginx.service # 访问 默认是80端口 your_ip:80
Configure Nginx
View the configuration file nginx.conf of Nginx.
Use
whereis nginxto findnginxThe installation location
is in /etc/nginx/conf. Add a new configuration file to the d folder, such as demo.conf, and configure the server's interface address and front-end entry file path:
upstream api {
server 127.0.0.1:8888; // 服务端
keepalive 2000;
}
server {
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/demo-frontend/dist/demo-web; // 前端资源位置
location / {
add_header Access-Control-Allow-Origin *;
}
location /api { // api 处理
proxy_pass http://api;
}
}
# Settings for a TLS enabled server.
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/frontend/demo.com/dist;
# ssl_certificate "/root/ssh/nginx/1_demo.com_bundle.crt";
# ssl_certificate_key "/root/ssh/nginx/2_demo.com.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
#. add_header Access-Control-Allow-Origin *;
# }
# to api restful service
# location /api {
# proxy_pass http://api;
# }
# error_page 404 /404.html;
# location = /404.html {
# }
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }Code comments Part of TLS is the transport encryption protocol
https, and the corresponding certificate needs to be added.
In the above code, we store the front-end static resources under /usr/share/nginx/frontend/demo.com/dist/, then we will package Just upload the content under dist/** to this directory file.
/usr/share/nginx/frontend/demo.com/dist/ actually points to the index.html entry file.
A relatively simple upload solution is to execute it directly on the user's local machine: rsync -avzh server username@62.**1.**.**:/usr/share /nginx/frontend/demo.com/dist/ index.html and its similar contents under the /dist project. Synchronize the packaged content to the corresponding location of the remote server. Then restart nginx, that is, nginx -s reload and you’re done.
Summary
Let’s summarize the whole process:
angular project packaging
Server installation nginx
nginx processing for back-end services
nginx handles front-end content
Upload the angular packaging file to the specified location on the server
Of course, you must apply for relevant information in advance The domain name, registration, related certificates, etc.
The idea is that simple. Of course, professional work should be left to operation and maintenance colleagues, don’t be too busy~
Original address: https://juejin.cn/post/7087417501486678030
Author: Jimmy
For more programming-related knowledge, please visit: Programming Teaching! !
The above is the detailed content of How to launch an Angular project? Let's talk about the online process with nginx!. For more information, please follow other related articles on the PHP Chinese website!
Python vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AMPython and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.
From C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AMThe shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.
JavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AMDifferent JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.
Beyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AMJavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.
Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Apr 11, 2025 am 08:23 AMI built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing
How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)Apr 11, 2025 am 08:22 AMThis article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base
JavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AMJavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.
The Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AMThe latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools

Dreamweaver CS6
Visual web development tools





