1.常用的Nginx命令
#1.操作Nginx命令的时候需要进入 nginx 目录中
cd /usr/local/nginx/sbin
#2.查看 nginx 版本号
./nginx -v
#3.启动 nginx
./nginx
#4.停止 nginx
./nginx -s stop
#5.重新加载 nginx
./nginx -s reload
2.Nginx的配置文件
Nginx的配置在/usr/local/nginx/conf/nginx.conf中:
配置文件共分为三大部分:
1.全局块:配置服务器整体运行的配置指令。
#user nobody;
worker_processes 1; #处理并发数的配置
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
2.events 块:影响 Nginx 服务器与用户的网络连接。
events {
worker_connections 1024; #支持的最大连接数为 1024
}
3.http块(包含http 全局块 + server 块)
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
这里先做配置文件的大概印象了解,后面再做细致分析。