安装位置:/usr/local/nginx
配置目录:/usr/local/nginx/conf
配置文件:/usr/local/nginx/conf/nginx.conf
启动命令:/usr/local/nginx/sbin/nginx

[root@limt sbin]# /usr/local/nginx/sbin/nginx -h
nginx version: nginx/1.7.9
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
1 指定配置文件启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c参数指定了要加载的nginx配置文件路径 [root@limt sbin]# ps -ef|grep nginx
root 4631 1 0 03:17 ? 00:00:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
nobody 4632 4631 0 03:17 ? 00:00:00 nginx: worker process
root 4634 4496 0 03:18 pts/0 00:00:00 grep nginx 2 修改配置文件后重新加载
kill -HUP 主进称号或进程号文件路径(/usr/local/nginx/logs/nginx.pid)
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
或者使用
/usr/nginx/sbin/nginx -s reload 3 测试配置文件正确性
[root@limt sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 4 停止nginx
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 主进程号

基本配置:/usr/local/nginx/conf/nginx.conf

#指定nginx worker进程运行用户以及用户组,默认nobody
user nobody;
#指定nginx要开启的进程数。最好与CPU个数相同
worker_processes 2; #用来定义全局错误日志文件。级别有:debug、info、notice、warn、error和crit。debug输出日志最为详细,criti输出日志最少
#error_log logs/error.log;
error_log logs/error.log notice;
#error_log logs/error.log info; #用来指定进程id的存储文件位置
pid logs/nginx.pid; #设定nginx的工作模式及连接上限
events {
#支持的工作模式有:select、poll、kqueue、epoll和rtsig.对于linux系统,epoll是首选模式
use epoll;
#定义nginx每个进程的最大连接数
worker_connections 2048;
} #HTTP服务器配置
http {
#实现对配置文件所包含的文件的设定,可以减少主配置文件的复杂度
include mime.types;
#设定默认类型为二进制流
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; #用于开启高效文件传输模式
sendfile on;
#防止TCP阻塞
#tcp_nopush on; #用于设置客户端连接保持活动的超时时间,超过这个时间,服务器会关闭该连接
#keepalive_timeout 0;
keepalive_timeout 65; #支持压缩传输,提高传输速度
#gzip on; #虚拟主机
server {
#监听端口
listen 80;
#主机头(域名)
server_name localhost; #web服务器的语言编码
#charset koi8-r; access_log logs/host.access.log main; #匹配url地址中有"/",则执行花括号中的配置
location / {
#虚拟主机的本地目录,完整路径:/opt/nginx/html,也可写绝对路径
root /var/nginx;
#默认索引的首页格式及顺序
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

Nginx日常操作和配置的更多相关文章

  1. linux下nginx日常操作

    一.检查配置文件语法 [root@node2 /]# nginx -tc /usr/local/nginx/conf/nginx.conf nginx: the configuration file ...

  2. apace日常操作和配置

    [root@limt modules]# /usr/sbin/apachectl -h Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file ...

  3. Nginx日常维护操作(3)

    一.简明nginx常用命令 1. 启动 Nginx /sbin/nginx   service nginx start   2. 停止 Nginx /sbin/nginx -s stop   /sbi ...

  4. nginx日常维护常用命令

    http://www.jb51.net/article/47750.htm 一.简明nginx常用命令 1. 启动 Nginx poechant@ubuntu:sudo ./sbin/nginx 2. ...

  5. 2.Nginx日常维护技巧

    Nginx日常维护技巧 Nginx配置正确性检查 nginx提供了配置文件调试功能,可以快速定义配置文件存在的问题.执行如下命令检测配置文件的正确性: [root@localhost 桌面]# whi ...

  6. Nginx简单操作

    Nginx简单操作 平滑重启:读取配置文件,正确后启动新nginx,关闭旧服务进程 # kill HUP nginx.pid # /usr/sbin/nginx -c /etc/nginx/nginx ...

  7. nginx四层负载均衡配置

    nginx四层负载均衡配置代理Mysql集群 环境如下: ip 192.168.6.203 Nginx ip 192.168.6.*(多台) Mysql 步骤一 查看Nginx是否安装stream模块 ...

  8. ORACLE日常操作手册

    转发自:http://blog.csdn.net/lichangzai/article/details/7955766 以前为开发人员编写的oracle基础操作手册,都基本的oracle操作和SQL语 ...

  9. nginx安装升级及配置详解

    1.简介 2.安装配置 3.配置文件介绍 4.启动.停止.平滑重启.升级 一.Nginx简介 Nginx(engine x)是俄罗斯人Igor Sysoev编写的一款高性能的http和反向代理服务器. ...

随机推荐

  1. 微博RPC框架motan入门笔记

    Motan 是一套高性能.易于使用的分布式远程服务调用(RPC)框架. 功能 支持通过spring配置方式集成,无需额外编写代码即可为服务提供分布式调用能力. 支持集成consul.zookeeper ...

  2. Phabricator是什么,代码审查工具

    Phabricator是什么? Phabricator支持两种代码审查工作流:"review"(提交前审查)和 "audit"(提交后审查). Phabrica ...

  3. linux下实现在程序运行时的函数替换(热补丁)

    声明:以下的代码成果,是参考了网上的injso技术,在本文的最后会给出地址,同时非常感谢injso技术原作者的分享. 但是injso文章中的代码存在一些问题,所以后面出现的代码是经过作者修改和检测的. ...

  4. CPU思考

    线程高并发 会导致CPU load长,线程大运算量和大量线程 会导致CPU利用率高 因为CPU处理都是原子操作的,8核CPU在同一时刻最多也只能处理8个线程,但是因为处理的非常快,所以即使几万个简单线 ...

  5. BZOJ4551——[Tjoi2016&Heoi2016]树

    1.题意: 给定一颗有根树(根为1),有以下 两种操作:1. 标记操作:对某个结点打上标记(在最开始,只有结点1有标记,其他结点均无标记,而且对于某个 结点,可以打多次标记.)2. 询问操作:询问某个 ...

  6. Python验证码6位自动生成器

    Python验证码6位自动生成器

  7. JSONObject.fromObject(map)(JSON与JAVA数据的转换)

    JSON与JAVA数据的转换(JSON 即 JavaScript Object Natation,它是一种轻量级的数据交换格式,非常适合于服务器与 JavaScript 的交互.) 上一篇文章中有这么 ...

  8. 此地址使用了一个通常用于网络浏览以外的端口。出于安全原因,Firefox 取消了该请求

    FirFox打开80以外的端口,会弹出以下提示: “此地址使用了一个通常用于网络浏览以外的端口.出于安全原因,Firefox 取消了该请求.”. 解决方法如下: 在Firefox地址栏输入about: ...

  9. C# Mvc中文件下载

    public ActionResult DownloadFile(string id) { var fileinfo = CommonAnnexService.Get(id); if (fileinf ...

  10. Java GridBagLayout 简单使用

    这里只介绍了很基础布局构建及使用,主要是关于 GridBagLayout. 首先整套流程大概是, 声明一个 GridBagLayout 对象 private GridBagLayout gridBag ...