安装位置:/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. Mac Sublime Text complie python .py error /bin/bash: shell_session_update: command not found

    1.get the rvm version rvm -v 2.make sure the version at least 1.26 above. 3.then go ahead rvm get he ...

  2. [NHibernate]Parent/Child

    系列文章 [Nhibernate]体系结构 [NHibernate]ISessionFactory配置 [NHibernate]持久化类(Persistent Classes) [NHibernate ...

  3. tyvj1005 采药

    描述 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个山洞 ...

  4. CSS样式自动换行(强制换行)与强制不换行

    自动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法 对于div,p等块级元素,正常文字的换行(亚洲文字和非亚洲文字)元素拥 ...

  5. Linux date命令详解

    1.显示时间 date命令可以按照指定格式显示日期,只键入date则以默认格式显示当前时间.如下: 如果需要以指定的格式显示日期,可以使用“+”开头的字符串指定其格式,详细格式如下: %n : 下一行 ...

  6. ReactiveCocoa源码拆分解析(二)

    (整个关于ReactiveCocoa的代码工程可以在https://github.com/qianhongqiang/QHQReactive下载) 上面抽丝剥茧的把最主要的信号机制给分离开了.但在RA ...

  7. C# 构建XML(简单示例)

    C# 构建XML的简单示例: var pars = new Dictionary<string, string> { {"url","https://www. ...

  8. 欧拉函数 - HDU1286

    欧拉函数的作用: 有[1,2.....n]这样一个集合,f(n)=这个集合中与n互质的元素的个数.欧拉函数描述了一些列与这个f(n)有关的一些性质,如下: 1.令p为一个素数,n = p ^ k,则 ...

  9. 【Maven】解决缺少Jar包问题

    解决办法:进入项目的根目录(即 pom.xml文件所在的目录)执行:mvn dependency:copy-dependencies完成后进入eclipse,发现项目不再报错前提条件:1,安装了mav ...

  10. js指定分隔符连接数组元素join()

    指定分隔符连接数组元素join() join()方法用于把数组中的所有元素放入一个字符串.元素是通过指定的分隔符进行分隔的. 语法: arrayObject.join(分隔符) 参数说明: 注意:返回 ...