nginx手册---用户基本配置
2015-05-11 19:21
423 查看
nginx--基本操作:
启动/关闭/重载配置指令:
格式:nginx -s signal [signal: stop/quit/reload/reopen]
运行nginx服务器命令行:$ nginx
signal详解:
stop: 快速关闭服务器;
quit: 友好关闭;
reload: 重载配置文件;当对nginx.conf文件做出修改后,使用此信号激活配置
reopen:打开日志文件;
查看nginx运行信息命令行:
ps -ax | grep nginx
nginx.conf配置文件框架:
nginx由模块构成,模块受directives控制,directives分为简单类型和块类型;
简单directive由名字/空格/参数; 组成;
块directive同简单directive一样,但是结束符[;]被[{}]包围;
当块directive包含directive,则称为context;
没在任何context内部的directive可被看作放在main context中;events和http在main context中,
server在http中,location在server中;
#后的文字是注释;
服务静态内容:
案例:要求Web服务器输出/var/data目录下的index.html和/var/images下的图片;
配置方案:
(1):在http context添加server context
http {
server {
}
}
(2):在server context中添加两个location context
http {
server {
location { }
location { }
}
}
(3):配置location context
http {
server {
location /{ root /var/data;} #取别名,当URI中第一个字符为/时,将把
#它映射为本地文件系统的/var/data目录
location /images/{ root /data;}
}
}
设置一个简单的代理服务:
nginx经常被用作代理服务器,代理服务器如同中转站,从客户端接受请求后发送给服务器或接受服务器
的回复再发送给客户端;
案例:设置最简单的nginx代理服务器,并且将两个服务器配置在一个nginx程序上
(1)首先设置主服务器:
server {
listen 8080;
root /var/www;
location / { }
}
#配置代理服务器:
server {
location / {
proxy_pass http://localhost:8080;
}
location ~\.(jpg|png|gif)$ {
root /data/images/;
}
}
启动/关闭/重载配置指令:
格式:nginx -s signal [signal: stop/quit/reload/reopen]
运行nginx服务器命令行:$ nginx
signal详解:
stop: 快速关闭服务器;
quit: 友好关闭;
reload: 重载配置文件;当对nginx.conf文件做出修改后,使用此信号激活配置
reopen:打开日志文件;
查看nginx运行信息命令行:
ps -ax | grep nginx
nginx.conf配置文件框架:
nginx由模块构成,模块受directives控制,directives分为简单类型和块类型;
简单directive由名字/空格/参数; 组成;
块directive同简单directive一样,但是结束符[;]被[{}]包围;
当块directive包含directive,则称为context;
没在任何context内部的directive可被看作放在main context中;events和http在main context中,
server在http中,location在server中;
#后的文字是注释;
服务静态内容:
案例:要求Web服务器输出/var/data目录下的index.html和/var/images下的图片;
配置方案:
(1):在http context添加server context
http {
server {
}
}
(2):在server context中添加两个location context
http {
server {
location { }
location { }
}
}
(3):配置location context
http {
server {
location /{ root /var/data;} #取别名,当URI中第一个字符为/时,将把
#它映射为本地文件系统的/var/data目录
location /images/{ root /data;}
}
}
设置一个简单的代理服务:
nginx经常被用作代理服务器,代理服务器如同中转站,从客户端接受请求后发送给服务器或接受服务器
的回复再发送给客户端;
案例:设置最简单的nginx代理服务器,并且将两个服务器配置在一个nginx程序上
(1)首先设置主服务器:
server {
listen 8080;
root /var/www;
location / { }
}
#配置代理服务器:
server {
location / {
proxy_pass http://localhost:8080;
}
location ~\.(jpg|png|gif)$ {
root /data/images/;
}
}
相关文章推荐
- Nginx配置文件基本应用参考手册
- Nginx配置文件基本应用参考手册
- 手把手学习nginx基本配置
- Nginx基本配置
- nginx 的基本配置
- Nginx服务的基本配置
- laravel部署到linux,nginx环境 php-fpm的配置中用户和组设定
- Nginx - Windows下Nginx基本安装和配置
- linux基本安全配置手册
- 《实战nginx》第3章-nginx基本配置与优化
- Nginx用户认证配置方法(域名/目录)详解
- ubuntu下nginx安装、基本配置及常用命令
- Nginx基本配置和参数说明
- nginx基本配置和参数说明
- nginx反向代理服务器安装、基本配置
- ubunut 安装nginx基本目录结构介绍和配置使用方法
- 【3】Nginx服务器基本配置简述
- Nginx基本配置(PHP)
- nginx的基本配置和虚拟主机的配置
- Nginx - Windows下Nginx基本安装和配置