基本命令
帮助命令:nginx -h
版本命令:nginx -v
编译命令:nginx -V
启动命令: ./nginx
查看进程: ps aux | grep nginx
检查配置文件:sudo nginx -t
指定启动配置文件:sudo nginx -c /usr/local/nginx/conf/nginx.conf
暴力停止服务:sudo nginx -s stop
优雅停止服务:sudo nginx -s quit
重新加载配置文件:sudo nginx -s reload
源码编译
./configure --prefix=/home/fdfs/nginx_bin --add-module=/home/yuqing/fastdfs-nginx-module/src
make&&make install
配置文件
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$time_local | $host | $status | $request_length | $bytes_sent | $upstream_addr | $upstream_response_time | '
'$http_referer | $remote_addr | $remote_user | $request | $request_uri | '
'$http_user_agent | $http_x_forwarded_for | $cookie_Mac';
log_format api_main escape=json '$time_local | $host | $status | $request_length | $bytes_sent | $upstream_addr | $upstream_response_time | '
'$http_referer | $remote_addr | $remote_user | $request | '
'$http_user_agent | $http_x_forwarded_for | $cookie_Mac | $http_authorization | $request_body';
access_log /var/log/nginx/access.log main;
client_max_body_size 1024m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 35;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
reco.conf
#upstream bms_nodes {
# server 127.0.0.1:5000 weight=1; #权值越高分配几率越大
#}
server {
# 监听端口号
listen 3070;
server_name 192.168.111.231;
access_log /var/log/nginx/oa.log main;
root /opt/html/reco;
index index.html;
location / {
try_files $uri /index.html;
}
# location ~* html {
# rewrite .* /index.html break;
# root /opt/html/siyue;
# }
}