-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nginx #36
Labels
Comments
nginx.conf配置文件,分为四部分:
每个部分都包含若干指令。 指令,有两类:
eg.用作静态服务器时 http {
server {
location / {
root /data/www; # 静态网页和文件
}
location /images/ {
root /data; # 图片等文件
}
}
}
# 以上便是在 http 模块下的 server 模块里新建了两个 location 模块 |
常用指令说明
... etc. |
实战
nginx.conf 配置文件的最后一行是 创建软连接: server {
listen 8369;
server_name m.hello.com;
root /.../dist;
index index.html index.htm;
location / {
etag on;
expires max;
try_files $uri $uri/ /index.html; # Vue 的前端路由可生效
}
} 然后重启 nginx。详见 安装 场景node.js+pm2+nginx
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
简介
Nginx 是 HTTP Server。常用来做:
它和 Tomcat 虽然都叫 web server,但二者有本质的不同。Tomcat 是 Application Server,常用来做应用容器,让 Java App 运行在其中。
HTTP Server 关心的是 HTTP 协议层面的传输和访问控制,所以 Nginx 有代理、负载均衡等功能。客户端通过 HTTP Server 访问服务器上存储的资源(HTML文件、图片文件等)。通过 CGI 技术,也可以将处理过的内容通过 HTTP Server 分发。但是,HTTP Server 始终只是把服务器上的文件,如实的通过 HTTP 协议传输给客户端。
而 Application Server,则是应用执行的容器。它首先需要支持开发语言的 Runtime(对于 Tomcat 而言,就是 Java),保证应用能正常运行。其次,需要支持应用相关的规范,比如类库、安全方面的特性(对于 Tomcat 就是要提供 JSP/Sevlet 运行需要的标准类库等)。为了方便,Application Server 也会集成 HTTP Server 的功能,但不如专业的 HTTP Server 那么强大。所以 Application Server 往往是运行在 HTTP Server 背后,执行应用,将动态内容转化为静态内容之后,通过 HTTP Server 分发到客户端。
Nginx 的优点是占用资源少。
安装
在 Mac 下
位置
ps aux | grep nginx
/..../nginx -t
The text was updated successfully, but these errors were encountered: