安装位置:/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. Debian 8中dpkg -i自动解决依赖关系

    dpkg -i 后#apt-get update &&apt-get -f install

  2. Burpsuite 重要插件

    1.Gason:Burpsuite-sqlmap插件,该插件可以让burp与sqlmap轻松对接,深度发掘SQL注入漏洞. 2.fuzzdb:fuzzing测试数据库,开源,深度测试SQL注入,xss ...

  3. 深入理解javascript原型和闭包(13)-【作用域】和【上下文环境】

    上文简单介绍了作用域,本文把作用域和上下文环境结合起来说一下,会理解的更深一些. 如上图,我们在上文中已经介绍了,除了全局作用域之外,每个函数都会创建自己的作用域,作用域在函数定义时就已经确定了.而不 ...

  4. php 去掉字符串的最后一个字符

    原字符串1,2,3,4,5,6, 去掉最后一个字符",",最终结果为1,2,3,4,5,6 代码如下: $str = "1,2,3,4,5,6,"; $news ...

  5. NGUI 学习笔记

    1.NGUI中UI的深度关系(新版NGUI 3.9): 在同一个Panel中,不管同不同Altas,各个UI的顺序受Depth影响 在不同Panel中,UI的顺序受Panel的Depth影响 例如Pa ...

  6. (二)SQL Server分区创建过程

    虽然分区有很多好处(一)SQL Server分区详解Partition,却不能随意使用:且不说分区管理的繁琐,只是跨分区带来的负面影响就需要我们好好分析是否有必要使用分区.一般分区创建的业务特点:用于 ...

  7. R语言进行数据预处理wranging

    R语言进行数据预处理wranging li_volleyball 2016年3月22日 data wrangling with R packages:tidyr dplyr Ground rules ...

  8. PHP HTML代码反转义

    后端为了防止xss的攻击,会过滤前端用户的输入的数据,这样虽然有效的避免xss攻击,但是会带来一个问题,要么全部过滤html留下不非法的数据,要么把HTML代码转义,但是转义之后又会直接在浏览器内显示 ...

  9. 清理系统 cmd

    echo 正在清除系统垃圾文件,请稍等......del /f /s /q %systemdrive%*.tmpdel /f /s /q %systemdrive%*._mpdel /f /s /q ...

  10. Spring基础知识

    Spring基础知识 利用spring完成松耦合 接口 public interface IOutputGenerator { public void generateOutput(); } 实现类 ...