目录
1.查看nginx安装后的目录位置
# yum安装
rpm -qc nginx
# 源码安装
find / -type d -name 'nginx'
2.nginx的目录结构:
[root@localhost nginx]# tree /usr/share/nginx
/usr/share/nginx
|-- client_body_temp
|-- fastcgi_temp # fastcgi 临时数据目录
|-- html # 这是编译安装时 Nginx 的默认站点目录, 前面已说明,
| |-- 50x.html
| `-- index.html
|-- proxy_temp # 临时目录
|-- scgi_temp # 临时目录
|-- uwsgi_temp # 临时目录
[root@localhost nginx]# tree /etc/nginx
/etc/nginx
|-- fastcgi.conf # fastcgi 相关参数的配置文件
|-- fastcgi.conf.default # fastcgi.conf 的原始备份
|-- fastcgi_params # fastcgi 的参数文件
|-- fastcgi_params.default
|-- koi-utf
|-- koi-win
|-- mime.types # 媒体类型
|-- mime.types.default
|-- nginx.conf # 这是 Nginx 默认的主配置文件
|-- nginx.conf.default
|-- scgi_params # SCgi 相关参数文件 , 一般用不到
|-- scgi_params.default
|-- uwsgi_params # uwsgi 相关参数文件, 一般用不到
|-- uwsgi_params.default
|-- win-utf
[root@localhost nginx]# tree /var/log/nginx/
/var/log/nginx/
|-- access.log # 这是 Nginx 的默认访问曰志文件, 使用 tail -f 可以实时观看网站用户访问情况信息
|-- error.log # 这是 Nginx 的错误日志文件, 如果 Nginx 出现启动故障等问题 ,查看错误日志
/run
|-- nginx.pid # Nginx 的 pid 文件, Nginx 进程启动后, 会把所有进程的ID号写到此文件
3.nginx的配置文件:
vim /etc/nginx/nginx.conf
# 内容
# worker 进程数量
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";
# 事件区块,设定 Nginx 的工作模式及连接数上限
events {
worker_connections 1024; # 每个worker进程可以处理的连接数
}
# HTTP 区块
http {
include mime.types; # 支持的媒体文件
default_type application/octet-stream; # 默认的媒体类型
sendfile on; # 高效传输模式
keepalive_timeout 65; # 超时时间
# server 区块
server {
listen 80; # 端口
server_name localhost; # 域名
location / { # 第一个location区块
root html; # 站点目录
index index.html index.htm; # 首页文件
}
error_page 500 502 503 504 /50x.html; # 错误信息配置
location = /50x.html { # 文件位置
root html; # 在哪找:路径
}
}
}