博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx笔记.
阅读量:6904 次
发布时间:2019-06-27

本文共 4394 字,大约阅读时间需要 14 分钟。

安装:

依赖的软件包:

gcc gcc-c++ autoconf automakezlib zlib-devel openssl opensll-devel pcre pcre-devel

到官方网站上下载nginx包:

解压:

tar -zxf nginx-x.x.tar.gz

安装三步走:./configure------- make------make install

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx \--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid \--lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module \--with-http_gzip_static_module --with-http_ssl_module --http-log-path=/var/log/nginx/access.log \--http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/\ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
[root@localhost ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf   启动nginx

查看nginx是否启动:

[root@localhost ~]# lsof -i:80COMMAND  PID  USER   FD   TYPE DEVICE SIZE NODE NAMEnginx   7802  root    6u  IPv4  22039       TCP *:http (LISTEN)nginx   7803 nginx    6u  IPv4  22039       TCP *:http (LISTEN)[root@localhost ~]# [root@localhost ~]# [root@localhost ~]# ps -ef | grep nginxroot      7802     1  0 09:36 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf master#主进程nginx     7803  7802  0 09:36 ?        00:00:00 nginx: worker process               #子进程                              root      7807  3696  0 09:36 pts/3    00:00:00 grep nginx[root@localhost ~]#
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf #检查配置文件的正确性。

nginx.conf 配置文件定义:

user  www www;       #使用的用户和组worker_processes  2; #指衍生进程数(一般设置为cpu总核数的两倍)。events {    worker_connections  1024; #允许最大连接数}http {    include       mime.types;    default_type  application/octet-stream;    server_names_hash_bucket_size 128;    client_header_buffer_size 32k;    large_client_header_buffers 4 32k;#-------------------------------------------------#设置客户端能够上传的文件大小。    client_max_body_size 8m;#-------------------------------------------------    sendfile        on;    tcp_nopush        on;    keepalive_timeout  65;    tcp_nodelay    on;    fastcgi_connect_timeout 300;    fastcgi_send_timeout 300;    fastcgi_read_timeout 300;    fastcgi_buffer_size 64k;    fastcgi_buffers 4 64k;    fastcgi_busy_buffers_size 128k;    fastcgi_temp_file_write_size 128k;#----------------------------------------#开启gzip压缩    gzip on;    gzip_min_length 1k;    gzip_buffers 4 16k;    gzip_http_version 1.1;    gzip_comp_level 2;    gzip_types    text/plain application/x-javascript text/css application/xml;    gzip_vary on;#----------------------------------------        server {        listen       80;        server_name  www.nimei.com;        index  index.html index.htm index.php;        root /data0/htdocs;        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$        {          expires       30d;        }        location ~ .*\.(js|css)?$        {          expires       1h;        }        log_format access '$remote_addr - $remote_user [$time_local] "$request"'                          '$status $body_bytes_sent "$http_referer"'                          '"$http_user_agent" $http_x_forwarded_for';        access_log /data1/logs/acess.log access;        }        server {        listen       80;    #虚拟主机监听的端口        server_name  www.nimei1.com;#虚拟主机域名或IP        access_log /data1/logs/vm1_access.log combined; 日志目录        location /                {        index  index.html index.htm;    #默认解析页面        root /data0/htdocs/nimei1;    #网站源码路径                }                }}

1.从容停止nginx(nginx启动停止由其pid决定):

kill -QUIT nginx主进程号kill -QUIT 7802 或者 kill -QUIT `cat /var/run/nginx/nginx.pid`

2.快速停止nginx:

kill -TERM ngixID 或者 kill -INT nginxID   nginxID-----主进程号[root@localhost ~]# kill -TERM 7886[root@localhost ~]# [root@localhost ~]# ps -ef | grep nginxroot      7900  3696  0 10:04 pts/3    00:00:00 grep nginx

3.强制停止nginx:

pkill -9 nginx

4.平滑启动nginx:

kill -HUP nginxID

Nginx信号控制说明:

TERM,INT 快速关闭nginxQUIT 从容关闭;HUP 平滑启动;USR1 重新打开日志文件(日志切割很有用)USR2  平滑升级可执行程序。WINCH  从容关闭工作。升级新版本关闭旧版本时用WINCH。

检查nginx配置文件的正确与否:

/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf[root@localhost ~]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.confthe configuration file /usr/local/nginx/conf/nginx.conf syntax is okconfiguration file /usr/local/nginx/conf/nginx.conf test is successful[root@localhost ~]#

 

 《未完待续》--------

 

转载于:https://www.cnblogs.com/osxlinux/p/3302454.html

你可能感兴趣的文章
BZOJ 1003([ZJOI2006]物流运输trans-SPFA+DP)
查看>>
Sharepoint学习笔记—习题系列--70-573习题解析 -(Q8-Q10)
查看>>
同时存在n个线程(n>5),需要写入或者读取一个名为test.txt的文件
查看>>
Android之MessageQueue、Looper、Handler与消息循环
查看>>
【Socket】linux黑客之网络嗅探底层原理
查看>>
Struts2.0 xml文件的配置(package,namespace,action)
查看>>
Comparing the MSTest and Nunit Frameworks
查看>>
C# 给枚举类型增加一个备注特性
查看>>
while循环的基本用法
查看>>
WEB数据挖掘(十六)——Aperture数据抽取(9):数据源
查看>>
31天重构学习笔记重新整理下载
查看>>
android 定时拍照并发送微博
查看>>
CSS中.和#区别
查看>>
多线程计算----pthread
查看>>
实战Apache+Tomcat集群和负载均衡
查看>>
第八周(2) Word邮件合并1
查看>>
Context 之我见
查看>>
让一个表单以post的方式在window.open的窗口中打开
查看>>
FreeNAS 9.1.1 发布,网络存储系统 - 开源中国社区
查看>>
极客技术专题【011期】:EasyUI初级教程
查看>>