1.主要配置文件及介紹
Ⅰ.nginx的安裝目錄

Snipaste_2019-10-26_15-36-13.png
Ⅱ.nginx.conf總配置文件解讀: vim nginx.conf 打開文件
# 運行用戶,默認是nginx,可以不進行設(shè)置
user nginx;
#Nginx進程,一般設(shè)置和cpu核數(shù)一樣
worker_processes 1;
#錯誤日志存放位置
error_log /var/log/nginx/error.log warn;
#進程pid存放位置
pid /var/run/nginx.pid;
events {
worker_connections 1024;#單個后臺進程的最大并發(fā)數(shù)
}
http {
include /etc/nginx/mime.types;#文件擴展名和類型映射表
default_type application/octet-stream;#默認的文件類型
#設(shè)置日志模式
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 /var/log/nginx/access.log main;#nginx訪問日志的存放位置
sendfile off;#是否開啟高效傳輸模式 on開啟 off關(guān)閉
#tcp_nopush on;#減少網(wǎng)絡(luò)報文段的數(shù)量
keepalive_timeout 65; #保持連接的時間,也叫超時時間
#gzip on;#開啟gzip壓縮模式
include /etc/nginx/conf.d/*.conf;#包含的子配置項的位置和文件
}
2.子配置文件及介紹
Ⅰ.default.conf子配置文件解讀
如果在騰訊云centos7上直接安裝nginx,會發(fā)現(xiàn)沒有該配置文件,請回到教程1,重裝系統(tǒng)后再自行配置yum源下載,單是卸載還會有nginx殘留配置

Snipaste_2019-10-27_15-07-43.png
server {
listen 80; #配置監(jiān)聽端口
server_name localhost; //配置域名
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html; #服務(wù)默認啟動目錄
index index.html index.htm; #默認訪問文件
}
#error_page 404 /404.html; # 配置404頁面
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html; #錯誤狀態(tài)碼的顯示頁面,配置后需要重啟
location = /50x.html {
root /usr/share/nginx/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;
#}
}
Ⅱ.網(wǎng)站根目錄

Snipaste_2019-10-27_10-35-13.png